Home > Back-end >  Ferror (fp) FILE *, fp ferror returns a different value is equal to what? Trouble bosses classificat
Ferror (fp) FILE *, fp ferror returns a different value is equal to what? Trouble bosses classificat

Time:09-27

#include
#include

Int main (void)
{
FILE *fp;
int ch;

If ((fp=fopen (" file. TXT ", "w"))==NULL)
{
Printf (" failed to open the file! \n");
The exit (EXIT_FAILURE);
}

Ch=fgetc (fp);// parameter ch up here? Can you delete?
If (ferror (fp))
{
Printf (" read the file file. An error occurred when TXT... \n");
}

fclose(fp);

return 0;
}

CodePudding user response:

Do you want to read a text file?

Char STR [256].

While (1)
{
The fgets (STR, sizeof (STR), fp);
If (feof (fp))
{
break;
}
//do your process
}
  • Related