Hi people, my first post here, hope its a good one.
I am trying to develop a program which will simulate a very simple name server, using the client-server frame.
My problem appears after the server receives the data (in form of a string) from the client and tries to compare this to strings within a file. The server should see if the data already exists, leaving file unchanged or enter into the file if it doesnt. I have used the functions strcmp(which always says that the data isnt in the file, even when it is) and strstr(which says that the data is in the file, even if the file is blank!).
Could someone please tell me what am I doing wrong?!
Thanks
while(fgets(charin, BUFFER, fp) != NULL)
{
if(strcmp(charin, buffer) == 0)
printf("already exists\n");
else
fprintf(fp, buffer);
}