#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

The parameter to getc() is a FILE pointer, not a char. Please read the man docs before attempting to use standard C functions.

>g.c:26: error: parse error before string constant
By not using proper indentation is hard for you to see that you have mismatched brackets.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.