C reading files

9 Views
Published
C read a file tutorial example explained

#C #read #file

int main()
{
FILE *pF = fopen("poem.txt", "r");
char buffer[255];

if(pF == NULL)
{
printf("Unable to open file!\n");
}
else
{
while(fgets(buffer, 255, pF) != NULL)
{
printf("%s", buffer);
}
}

fclose(pF);

return 0;
}
Category
Bro Code
Tags
language, for, beginners
Be the first to comment