Search code examples
cformat-string

Format string confusion in fscanf function in C


I'm unable to understand below this line , could somebody tell me what it does ?

fscanf(file_pointer, "%*[^\n]");

Solution

  • From the docs one might see, that:

    * - assignment-suppressing character which is used not to assign the value being read to any receiveing argument of fscanf.

    [^\n] - conversion specifier which matches any symbol except (^) new line (\n).

    As a result, this fscanf reads all symbols until new line is met.