line.c
来自「国外网站上的一些精典的C程序」· C语言 代码 · 共 44 行
C
44 行
/*** LINE.C** Simple filter to add line-numbers to files**** public domain demo by Bob Stout**** Syntax:** LINE may be used at the end of a command-line or in the middle, e.g.**** <type|cat> myfile.c | line | more** add line-numbers and show myfile.c one screen at a time**** or **** <type|cat> myfile.c | line > lpt1** print listing with line numbers**** or simply**** line < myfile.c > file.out*/#include <stdio.h>#include <stdlib.h>int main(){ static unsigned long linenumber = 0; int ch, newline = 1; while (EOF != (ch = getchar())) { if (newline) { printf("%06lu: ", ++linenumber); newline = 0; } putchar(ch); if ('\n' == ch) newline = 1; } return EXIT_SUCCESS;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?