done some modifications to the code.
ive got this:
Code:
//program to count words in a user supplied string
#include <stdio.h>
char line [100];
int wordcount(char line);
int numberOfWords = 0;
int main()
{
printf("Enter a line and I will count the number of words: ");
fgets(line, sizeof(line), stdin);
printf("There are %d words in the sentance.", wordcount(*line));
}
//function: wordcount
//this function takes in the sentance variable, counts to each space character defined as ' ' and prints out the number of times
//it saw the ' ' (space) character.
int wordcount(char line)
{
int index = 0;
for(index <= sizeof(line), line == ' ', ++line)
{
++numberOfWords;
}
return numberOfWords;
}
but im getting an error during compilation.
Code:
C:\CODE>gcc -o wordcount wordcount.c
wordcount.c: In function `wordcount':
wordcount.c:23: error: syntax error before ')'
does anyone see what the compiler talking about?
thanks