没有获取当前行的功能。您必须自己跟踪它。像这样:
FILE *file;
int c, line;
file = fopen("myfile.txt", "rt");
line = 0; /* 1 if you want to call the first line number 1 */
while ((c = fgetc(file)) != EOF) {
if (c == '\n')
++line;
/*
... do stuff ...
*/
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
33582 次 |
| 最近记录: |