Hello everyone,i need help here(urgent!!):
here is what my program for:
1.user will enter a string not more than 300 words.
2.change string to lowercase
3.count each word occurrence
example:
This is a test. This program will count number of each word occurrence.
this = 2
is = 1
a = 1
test = 1
program = 1
will = 1
count = 1
number = 1
of = 1
each = 1
word = 1
occurrence = 1
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main ()
{
int tokenCount,i;
char string[7500];
char *pToken;
printf("Please enter a paragraph, maximum of 300 words: \n");
gets (string);
//change uppercase to lowercase
for (i=0; i<7500; ++i) string[i] = tolower (string[i]);
//to break the string
tokenCount = 0; //to count number of words
pToken = strtok(string," ");
while (pToken != NULL)
{
tokenCount ++;
printf ("[%2d] %s\n",tokenCount, pToken);
pToken = strtok(NULL,", . ; : # ! @ $ % ^ & * ( ) - _ = + { } [ ] | ` ~ < > / ? \\ 1 2 3 4 5 6 7 8 9 0");
}
return 0;
}