Groovy hepcat Matt was jivin' on 19 Apr 2005 14:57:52 -0700 in
comp.lang.c.
1.5.2 Character Counting's a cool scene! Dig it!
Alright, so I'm a little confused here...what exactly does this do?
I've run it and it doesn't display anything, so I've typed some things
into it, to see if it'd do something then, but to no avail. Can
somebody explain to me what this does?:
#include <stdio.h>
/* count characters in input; 2nd version */
main()
{
double nc;
Liar, liar! Pants on fire! K&R2 has no such thing in section 1.5.2.
There the real nc is a long, not a double.
for(nc = 0; getchar() != EOF; ++nc)
;
printf("%.0f\n", nc);
}
It's confusing the way they say it. Any help is GREATLY appreciated!
As I said before in another thread, and still not trying to be mean
or cause offence, if you can't understand such a simple program when
its purpose is clearly explained on the same (and a little on the
previous) page, then programming is probably not the best thing for
you.
This program counts the number of characters in its input. Clear?
You type in any characters at all, or redirect/pipe input from another
source such as a file (if your system allows it), and at the end it
outputs the number of characters typed/piped/read. How do you let the
program know that you want to end the input when you are entering it
manually from a keyboard? Well, that's a FAQ. I'm going to tell you
just this once, but in future please consult the FAQ list (see URL
below). It depends. It depends on the system. For example, on
DOS/Windows you type Ctrl + z followed by enter.
The FAQ can be found at
http://www.eskimo.com/~scs/C-faq/top.html.
--
Dig the even newer still, yet more improved, sig!
http://alphalink.com.au/~phaywood/
"Ain't I'm a dog?" - Ronny Self, Ain't I'm a Dog, written by G. Sherry & W. Walker.
I know it's not "technically correct" English; but since when was rock & roll "technically correct"?