麻烦解释下这段c语言代码中注释的部分
#include<stdio.h>#include<ctype.h>#include<stdbool.h>#defineSTOP'|'intmain(void){char...
#include<stdio.h>#include<ctype.h>#include<stdbool.h>#define STOP '|'int main(void) { char c; char prev; long n_chars = 0L; int n_lines = 0; int n_words = 0; int p_lines = 0; bool inword = false; //这一行什么意思 printf("Enter text to be analyzed (| to terminate):\n"); prev = '\n'; //这一行有什么用 while ((c = getchar()) != STOP) { n_chars++; if (c == '\n') n_lines++; if (!isspace(c) && !inword) { inword = true; n_words++; } if (isspace(c) && inword) inword = false; prev = c; //什么意思,有什么用? } if (prev != '\n') p_lines = 1; printf("characters = %ld, words = %d, lines = %d,", n_chars, n_words, n_lines); printf("partial lines = %d\n", p_lines); getchar(); getchar(); return 0;}
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询