If you are referring to the line number within your c source, most compilers support the __LINE__
macro.
If you want to count line numbers of arbitrary text files in c, the following functions should be starting points:
- fopen() to open a file for reading
- fgets() to read lines
- eof() to check for end of file
- fclose() to close the file
Combining these into a line counter is left as an exercise to the reader :)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…