My code is to check if a given word is a palindrome or not. But when I run it, I am not getting correct results. Please help me find my mistakes as I am still in the process of learning C.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main ()
{
char a[40];
printf("Enter the word - ") ;
scanf("%s" , &a);
printf("Reversed - %s \n " , strrev(a)) ;
if(a == strrev(a)){
printf("Yes");
}
else{
printf("No");
}
return 0;
}
The outputs are always random. Even it happened when I tried to do another project. Then I had to simply copy paste the code and it worked.
Anticipating favourable response.