📄 line.c
字号:
/* +++Date last modified: 05-Jul-1997 */
/*
** 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -