I want to know why this code instead of writing a letter each second waits to read all the letters before printing them.
#include <stdio.h>
#include <unistd.h>
int main ()
{
FILE *fp;
int c;
fp = fopen ("hello.txt", "r");
if (fp == NULL)
{
perror ("Cannot open file");
return (-1);
}
while (1)
{
c = fgetc (fp);
if (feof (fp))
{
break;
}
printf("%c", c);
sleep(1);
}
printf("\n");
fclose (fp);
return (0);
}