c语言统计输入字符数及行数
作者:互联网
1、
#include <stdio.h> #define STOP '|' int main(void) { char ch; int chnum = 0; int lines = 0; while((ch = getchar()) != STOP) { if(ch != '\n') chnum++; else lines++; } printf("ch number: %d.\n", chnum); printf("lines : %d.\n", lines + 1); return 0; }
标签:字符,ch,int,STOP,lines,行数,printf,数及,chnum 来源: https://www.cnblogs.com/liujiaxin2018/p/15171959.html