C-Kurs/PalindromeMusterlösung
< C-Kurs
Version vom 24. September 2009, 09:45 Uhr von 130.149.17.49 (Diskussion) (Die Seite wurde neu angelegt: „<pre> #include <stdio.h> char* reverse(char wort[]) { char* result = calloc(strlen(wort) + 1, sizeof(char)); int i; for(i = 1; i <= strlen(wort); i++) *(res...“)
#include <stdio.h> char* reverse(char wort[]) { char* result = calloc(strlen(wort) + 1, sizeof(char)); int i; for(i = 1; i <= strlen(wort); i++) *(result++) = wort[strlen(wort) - i]; *result = '\0'; return result - strlen(wort); } int isReverse(char* wort1, char* wort2) { char* wort1Rev = reverse(wort1); return strcmp(wort1Rev, wort2); } int main(int argc, char* argv[]) { if (argc < 2) return -1; printf("%s\n%s\n", argv[1], reverse(argv[1])); pr