View Single Post
Old 03-21-2003, 04:51 PM   #1 (permalink)
DemosthenesB
Registered User
 
Join Date: Mar 2003
Posts: 7
DemosthenesB is on a distinguished road
Character Counting Program

I just started to learn C with the book "The C Programming Language." I am only in the first chapter and am already experiencing problems

There is an section on Character Input and Output. The first example is a "Character Counting" program. The script is a s follows:

Code:
#include <stdio.h>

/*count chars in input, 1st version*/

main ()
{
	long nc;

	nc = 0;
	while (getchar() != EOF)
		++nc;
	printf("%ld\n", nc);
}
What am I supposed to get when I run the program? So far all I can do it type and the text will show, nothing else.

P.S. Just to let you know I am using Slackware Linux, maybe that has something to do with it...
DemosthenesB is offline   Reply With Quote