0
#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

3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Aia
0

>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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.