say i wanted to store a phrase in a string, tokenize it , and run the words through a counter to see how freqently the numbers of the letters in the words appear.


for intstance

say i entered

"today is a good day to die!"

i want it to say

# of letters in word freqency of words
1 1
2 2
3 2
4 1
5 1

i have some code to show what ive been "trying " to do

Code:



char string1[]="the mathamatics curriculum guidelines envision that all students.";

char *tokenPtr;
tokenPtr = strtok (string1, " ");


while (string1 !='\0'){
   
tokenPtr = strtok(NULL, " ");
int x = strlen(string1) // i know that only does one word, but i dont know how to make it do the whole phrase :(	
switch(x){
case 1:
	ctr1++;
    break;
case 2:
	ctr2++;
    break;
case 3:
	ctr3++;
    break;
case 4:
	ctr4++;
    break;
case 5:
	ctr5++;
    break;