DEV_BUT1/DEV1.1S/TP01/Palindromes.c

30 lines
497 B
C
Raw Normal View History

2023-02-08 11:18:16 +01:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char* inverse(const char* s){
int i;
int e=0;
char* crocs;
int longueur = (int) strlen(s);
crocs = (char*) malloc(longueur+1);
for (i=longueur-1;i>=0;--i) {
crocs[e] = s[i];
e++;
crocs[longueur] = '\0';
}
return crocs;
}
int main(int argc, char** argv) {
int c;
for(c=1; c< argc; c++){
if (strcmp(argv[c], inverse(argv[c]))== 0){
printf("est un palindrome \n");
}
else{
printf("non \n");
}
}
return 0;
}