fgets returns null if a line cannot be read. You should check for this.
Code:
#include<stdio.h>
main() {
FILE *s,*d;
char a[60];
s=fopen("temp" ,"r");
while(fgets(a,55,s)) {
printf(" %s is the string in the temp file\n",a);
}
}
feof can only see that the end of file has been reached after you attempt to read beyond the end of the file.
From feof documentation:
Checks whether the End-of-File indicator associated with stream is set, returning a value different from zero if it is.
This indicator is generally set by a previous operation on the stream that reached the End-of-File.