I have to search a specific string in a file.Here i am using 'strcmp' function but its not working properly.when am compiling it in linux using gcc it does not shows any error.i couldn't catch the mistake.
#include<stdio.h>
#include<string.h>
void main()
{
FILE * fpi;
int totallines=0,headerlines;
char s1[100],s2[100],str1[]="END OF HEADER";
fpi=fopen("rinexinput.txt","r");
if(fpi==NULL)
{
printf("error in opening file");
}
while(!feof(fpi))
{
fgets(s1,100,fpi);
totallines++;
if(strcmp(str1,s1) == 0)
{
headerlines=totallines;
exit(0);
}
}
printf("%s %d\n",s1,headerlines);
}