我目前正在学习“C 编程语言”。但是,我被困在 getchar() 部分。
我附加的代码与教科书匹配,应该计算输入中存在的字符。
#include "stdio.h"
void countChar(){
long nc = 0;
while (getchar() != EOF)
++nc;
printf("%ld\n", nc);
运行代码并输入内容后,不会返回任何字符数。这是 printf 的问题还是我的代码中的其他问题?
任何帮助将不胜感激。
#include "stdio.h"
应该是
#include <stdio.h>