Read strings from a file : <pre><code> FILE *fp;
char name[50];
fp=fopen("stu.txt","r");
while(fgets(name,50,fp)!=NULL)
{

    printf(" %s",name);
    fgets(name,50,fp);

}
fclose(fp);
</code></pre>

<p>In my file there are 4 names in 4 different lines but the output only displays the 1st and the 3rd name.What's wrong?I know it's very basic but this has taken up a lot of my time.</p>
