예제 #1
0
int strPalindrome (const char *s)
{
	int i, j = 0;
	int size = strlen(s);
	char d[40] = {""};
	for (i = size-1; i >= 0; i--)
	{	
		d[j] = s[i];
		j++;
	}
	printStringArray(d);
	printStringArray(s);
	j = 0;
	for (i = 0; i < size; i++)
	{
		if (s[i] == d[i]);
		{
			j++;
		}
	}
	printf("value of j: %d", j);
	if (j == size)
	{
		return 1;
	}else
	{
		return 0;
	}
}
예제 #2
0
파일: p1.c 프로젝트: medium-endian/GDIMES
void testStringBubbleSort(char *filename) {
  int length;
  char **plaetzchenListe;

  plaetzchenListe = readRezeptListe(filename);
  length = getArrayLength(plaetzchenListe);
  printf("---- testStringBubbleSort() -----------------\n\n");
  printf("Es sind %i Rezepte in der Liste\n", length);

  stringBubbleSort(length, plaetzchenListe);

  printStringArray(getArrayLength(plaetzchenListe), plaetzchenListe);

  cleanup(plaetzchenListe); // memory leaks vermeiden -- hier zwar nicht
                            // notwendig aber sinnvoll!
}
예제 #3
0
int main (int argc, char* argv[])
{
	char str[] = {"Every good boy does fine."};
	char str2[30] = {"Every good boy does fine."};
	char str3[30] = {""};

	//Test Word Count
	int wordCount = strWordCount(str);
	printf("Word count: %d\n", wordCount);
	//end test word count
	//
	//Test str to upper.
	strToUpper(str, str2);
	printStringArray(str);
	printStringArray(str2);
	//end test str to upper.
	//
	//Test str Strip
	char c = 'o';
	strStrip(str, c, str2);
	printStringArray(str);
	printStringArray(str2);
	//end test str Strip
	//
	//Test str Substring
	char d[] = {"boy"};
	printf("Where does the word boy start? %d", strIsSubstring(str, d));
	//end test str is Substring
	//
	//Test strSubstitute
	char e, g;
	e = 'g';
	g = 'o';
	strSubstitute(str, e, g, str2);
	printStringArray(str);
	printStringArray(str2);
	//end test strSubstitute
	//
	//Test strReverse
	strReverse(str, str2);
	printStringArray(str);
	printStringArray(str2);
	//Test Palindrome
	char tacocat[] = {"tacocat"};
	printf("Is tacocat a Palindrome? %d", strPalindrome(tacocat));
	//end palindrome test
	//
	//Test strSplit
	strSplit (str, 'o', 3, str3, str2);
	printf("The starting str\n");
	printStringArray(str);
	printf("The second half of str\n");
	printStringArray(str2);
	printf("The first half of str\n");
	printStringArray(str3);
	
}