Use fscanf to read from given line

后端 未结 3 567
萌比男神i
萌比男神i 2021-01-22 14:40

I want read a txt file that has up to 10 lines. The file is formatted like this on all lines:

1 1 8
2 2 3
3 1 15
4 2 7

I\'m trying to write a f

3条回答
  •  没有蜡笔的小新
    2021-01-22 15:23

    you need to use checks for your input scans. you might potentially run into errors or EOF.

    if(line < 1)       //check for invalid line number
    {
        printf("Invalid line number..aborting\n");
        exit(1);   //aborting is optional
    }
    for(int i = 0;i

提交回复
热议问题