What is the fastest way to count lines and words in a text file in ANSI C?

前端 未结 3 1586
甜味超标
甜味超标 2020-12-04 03:29

What is the fastest way to count lines and words in a text file in pure ANSI C?

A word is terminated by a space or period. Line is terminated by \'\\n\'

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-04 03:53

    • Read the file in
    • Iterate over characters increment character counter
    • Check if space/end of line increment word counter
    • Repeat second and third steps until EOF

提交回复
热议问题