N
newby2c
Greetings all,
Here is another incredibly silly question. I feel foolish asking it, but
i've no other choice. I was going through K&R2 and at section 1.5.2
(Character Counting), I decided to try out the program:
/* count characters in input; 1st version */
#include <stdio.h>
int main(void)
{
long nc;
nc=0;
while(getchar()!=EOF)
++nc;
printf("%ld\n",nc);
return 0;
}
after compiling it, I ran it. I typed in some letters and numbers and they
were repeated on the screen (as expected). But then what? How do I get the
count of the characters typed? I tried ctrl-d (I get a diamond), ctrl-z
(program terminates), and ctrl-c (program terminates). What am I doing wrong
or what am I understanding wrong? Any help is much appreciated.
Best,
newby2c
Here is another incredibly silly question. I feel foolish asking it, but
i've no other choice. I was going through K&R2 and at section 1.5.2
(Character Counting), I decided to try out the program:
/* count characters in input; 1st version */
#include <stdio.h>
int main(void)
{
long nc;
nc=0;
while(getchar()!=EOF)
++nc;
printf("%ld\n",nc);
return 0;
}
after compiling it, I ran it. I typed in some letters and numbers and they
were repeated on the screen (as expected). But then what? How do I get the
count of the characters typed? I tried ctrl-d (I get a diamond), ctrl-z
(program terminates), and ctrl-c (program terminates). What am I doing wrong
or what am I understanding wrong? Any help is much appreciated.
Best,
newby2c