标签:c
编写一个程序,从标准输入读取几行输入。每行输入都要打印到标准输出上,前面加上行号。
在编写这个程序的时候要使这个程序能够处理的输入行的长度没有限制。
#include <stdio.h> #include <stdlib.h> int main() { char ch = ‘0‘; int n = 1; int flag = 1; while (1) { printf("please input the line: "); do { scanf("%c", &ch); if (1 == flag) { flag = 0; printf("%d ", n); } printf("%c", ch); } while (ch != ‘\n‘); flag = 1; n++; } system("pause"); return 0; }
编写一个程序,从标准输入读取几行输入。每行输入都要打印到标准输出上,前面加上行号。
标签:c
原文地址:http://zhaoguanwen.blog.51cto.com/10824932/1711992