scanf, FSCANF is similar, reads input from the stream and assigns a value to the variable
int scanf (const char *format, ...)
int fscanf (FILE *stream, const char *format,...)
%c single character
%[] a character set
* Input entries are skipped after they are read in, and no variables are assigned
scanf, fscanf automatically skips tabs and spaces, other characters give variables, returns the number of variables (integers) that were successfully assigned, and returns EOF when an error occurs
%[^\n] means reading a whole line, ^ means "non", the previous reference to%[] represents a character set, so%[^\n] represents "a collection of all characters before a newline", and then ends the read-in.
But after doing this, the newline character is not yet read.
As mentioned earlier, * indicates that the input is skipped after it is read in, so%*c reads a character, but does not assign any variable, so it can be written
FSCANF (FP,%[^\n]%*c, str)
Where FP is a file stream pointer, str is a string variable, this code means: read everything before the line break, assign to STR, and then skip the line break, pointing to the next line of content.
C + + fscanf reads a whole line