FUNCTION
word_count
This function determines the number of words in a string.
You're viewing an older version of this page (#5608). View the current version.
Interface
The assumptions involved are:
- The string is null terminated
- The words separation char is only a space and nothing else.
Example 1
#include <cstdio>
#include<codecogs/strings/word_count.h>
int main () {
char * sz = "The quick brown fox jumps over the lazy dog.";
int nWordCount = Strings::word_count (sz);
printf ("The word count is %d", nWordCount);
return 0;
}Output:
9Parameters
text
The null terminated input string
Returns
Number of words in the input string.
This function's source code is only visible to registered users — documentation and the calculator above are free to use either way. Sign in to see it.