G
gk245
Basically, i want to make a function that will receive a sentence or
phrase, and count its words.
It would start like this (i think):
#include <stdio.h>
int count ( char sentence [] )
{
char string [100];
printf("Enter sentence: ");
scanf() //not sure if this is the right thing to do..
etc...
}
Problem is that i am not sure if there are any functions that make this
easier. I looked at fgets() but that one wants a file. Also, what
happens if someone puts in a long sentence? I mean, the size of the
array would be a fixed size in the function, no?
Any hints are fine, not looking for the entire code.
Thanks.
phrase, and count its words.
It would start like this (i think):
#include <stdio.h>
int count ( char sentence [] )
{
char string [100];
printf("Enter sentence: ");
scanf() //not sure if this is the right thing to do..
etc...
}
Problem is that i am not sure if there are any functions that make this
easier. I looked at fgets() but that one wants a file. Also, what
happens if someone puts in a long sentence? I mean, the size of the
array would be a fixed size in the function, no?
Any hints are fine, not looking for the entire code.
Thanks.