How to skip a line when fscanning a text file?

前端 未结 4 631
隐瞒了意图╮
隐瞒了意图╮ 2020-11-30 09:03

I want to scan a file and skip a line of text before reading. I tried:

fscanf(pointer,\"\\n\",&(*struct).test[i][j]);

But this syntax s

4条回答
  •  隐瞒了意图╮
    2020-11-30 09:32

    fgets will get one line, and set the file pointer starting at the next line. Then, you can start reading what you wish after that first line.

    char buffer[100];
    fgets(buffer, 100, pointer);
    

    It works as long as your first line is less than 100 characters long. Otherwise, you must check and loop.

提交回复
热议问题