#include <stdio.h>
#include<string.h>
main()
{
FILE * myfileptr; // a pointer declared to the file stream.
char sc; // a character which will be input from the file.
// main code...
myfileptr=fopen("words","r"); //open the file hopefully
while((sc=getc(myfileptr))!=EOF) //get a char
{
if(sc)printf("%c",sc); //dump it to screen
}
printf("EOF\n");
}
getc("%c",sc);
if(strlen(sc)%2==0) printf("Word not palindrom");
else
{
int i;
for(i=0;i<strlen(sc);i+=1)
if(sc[i]!=sc[strlen(sc)-1-i])
{
printf("Word not palindrom");
break;
}
if(i==strlen(sc)) printf("The word is palindrom");
}
}
i cant get my program to print this way
for example
ada palindrome
back not a palindrome
all i get is the words from the file it is opening.
now i get
g.c:26: error: parse error before string constant
g.c:26: warning: data definition has no type or sto