So im making a program that checks if a word is a palindrome but when it comes to comparing the final strings at the end even if they are the same i get a -1 result edit: copy pasted the exact same code i used
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
int main()
{
char input[50];
char test[50];
int ret;
printf("Enter word or phrase to compare ");
fgets(input,sizeof(input),stdin);
strcpy(test,input);
strrev(input);
ret = strcmp(test,input);
if(ret == 0)
printf("\n this is a palindrome ");
else
printf("\n this is not a palindrome");
}
For input i used "ala" which i know is a palindrome i get the result
this is not a palindrome