C-Kurs/PalindromeMusterlösung
< C-Kurs(Weitergeleitet von Ckurs/PalindromeMusterlösung)
#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])); printf("%d\n", isReverse(argv[1], argv[1])); }