#include <stdio.h>
int main(int argc, const char * argv[])
{
long nc;
nc=0;
while (getchar()!=EOF) {
++nc;
printf("%ld\n", nc);
}
}
This is the code, and when I typed a character, it will print 1 then print 2, even if I have only typed once.
I am using Xcode.
But you did press
return, didn’t you ? Try pressing CTRL+D or watch out for the newline in the loop. Maybe something like this ?