Summary: I have a problem from "Learn C on the Mac"
Keywords: simple C youKnowTheAnswer help
Organization: The World @ Software Tool & Die
Date: Thu, 12 Nov 1992 08:17:04 GMT
Lines: 60
Hi folks,
I picked up "Learn C on the Macintosh" and am having a problem with modifying the "wordCount.c" code to not only analyze the # of words typed, but to print them out on separate lines (one word to a line) whenever white space is found. Something about my code just "ain't happenin'". I get the right number of characters printed, but the characters aren't what they should be (something like "car" turning into "***" - the "*" character not actually being a "*").
HELP? Source code follows:
______-------________-----
#include <stdio.h>
#define MAX_LINE_LENGTH 200
#define C_RETURN '\n'
#define C_TAB '\t'
#define C_SPACE ' '
void main( void )
{
char line[ MAX_LINE_LENGTH ], *charPtr, inWord;
int numWords;
printf( "Type a line of text, please:\n" );
charPtr = line;
numWords = 0;
inWord = FALSE;
while ( ( *charPtr = getchar() ) != C_RETURN )
{
if ( (*charPtr != C_TAB) && (*charPtr != C_SPACE) )