#include <stdio.h>
#include<string.h>
main()
{
FILE * words; // 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=gets(myfileptr))!=EOF) //get a char
{
if(sc)printf("%c",sc); //dump it to screen
}
printf("EOF\n");
gets("%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");
}
my errors are:
g.c:10: error: 'myfileptr' undeclared (first use in this function)
g.c:10: error: (Each undeclared identifier is reported only once
g.c:10: error: for each function it appears in.)
g.c:12: warning: assignment makes integer from pointer without a cast
g.c:20: error: too many arguments to function 'gets'
g.c:21: warning: passing argument 1 of 'strlen' makes pointer from integer without a cast
g.c:25: warning: passing argument 1 of 'strlen' makes pointer from integer without a cast
g.c:26: error: subscripted value is neither array nor pointer
g.c:26: warning: passing argument 1 of 'strlen' makes pointer from integer without a cast
g.c:26: error: subscripted value is neither array nor pointer
g.c:31: warning: passing argument 1 of 'strlen' makes pointer from integer without a cast
g.c:33: error: parse error at end of input

New Topic/Question
Reply




MultiQuote




|