#include <iostream>
using namespace std;
void main ()
{
char *tokenString, *c, string[80];
cout << "Input a string: ";
cin.getline(string, 80);
cout << "The entered string is: " << string << endl;
c = string;
while (*c)
{
if ((*c >= 'a') && (*c <= 'z'))
*c = (*c - 'a') + 'A';
++c;
}
cout << "The string in all upper case letters is: " << string << endl;
tokenString = string;
char *tokenPtr, *nullPtr= NULL;
cout << "The string to be tokenized is:\n" << tokenString
<< "\n\nThe tokens are:\n";
tokenPtr = strtok( tokenString, " " );
while ( tokenPtr != NULL ) {
cout << tokenPtr << '\n';
tokenPtr = strtok(nullPtr, " " );
}
}
1) i am trying to get user to input a list of words and then i need to:
* sort them in alpha orders
* and display how many time each word is present in the string. ignore case. for ex: bob == BOB
2) my current code can takes a string input and convert all the words in the string into upper case and tokenized them into parts.
3) i need help on how to compare each of the tokenized words and see if they are equal.
4) samples of ideal inputs and outputs i need my code to do
input
bill bill joe jack dan bob BILL BOB
output
BILL BOB DAN JACK JOE
BILL 3
BOB 2
DAN 1
JACK 1
JOE 1
THANKS