l5.1d
来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 1D 代码 · 共 49 行
1D
49 行
#printWrite a program that counts the blanks, tabs, and newlinesin its input, and prints the total. Don't forget todefine the value of EOF at the beginning of your program.The best way is to add #include <stdio.h>as the first line of your program.The ____must be in column 1.(See page 143 of the C book.)You may also have to saycc name.c -lSto compile the program.#once #create RefThis is some junk thatcontains blanks tabs and newlines.#usera.out <Ref >test1a.out </dev/null >test2grep 13 test1 >/dev/null || grep 0 test2 >/dev/null#succeedOne possible solution: #include <stdio.h>main(){ int n, c; n = 0; while ((c = getchar()) != EOF) if (c == ' ' || c == '\t' || c == '\n') n++; printf("%d\n", n);}This program won't work on huge files, because an intisn't big enough.#log#next5.1e 105.2e 5
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?