you dont need to reverse the string to check if its palindrome.
the algorithm works like:
get the length of the string;
loop from zero to length of string by 2;
compare the characters on position loop count with lenght minus loop count minus 1;
if the are not equal its not a palindrom;
its a palindrome if the loop finished;
for example: "test":
first step: compare 't' with 't'
second step: compare 'e' with 's' --> not a palindrom
for example "palap":
first step: compare 'p' with 'p'
second step: compare 'a' with 'a'
third step: compare 'l' with 'l'
now we know that it is a palindrom.
try thisone:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int palindrom(char * s){
int i;
int l = strlen(s);
for(i=0;i<=l/2;i++)
if(s[i]!=s[l-i-1]) return 0;
return 1;
}
int main(void) {
char * test = "test";
char * pal = "palap";
printf("%s %d", test, palindrom(test));
printf("%s %d", pal, palindrom(pal));
return 0;
}