If not, is the intent that your program will read the dictionary into memory and repeatedly search for words entered by the user, or that your program will search for a single word in your dictionary and exit? Does the user have supply the leading and trailing spaces before the separating --- in your dictionary. Does the user have to match case as it appears in your dictionary, or is your program supposed to do a case insensitive search?
i used that "---" only to separate words and meanings , it will appear in the program as a Space
The mini-dictionary already has words and their corresponding meanings. The
user input a sentence (string of characters) to perform one of the following
operations on it.
The Operations are:
Separate sentence into tokens (i.e. separate words)
Get the frequency of each word (i.e. number of repetitions of each word),
from the sentence.
Display the corresponding meaning, from the dictionary, for each unrepeated
token (a word) in given sentence.
And ask the user if he wants to perform any additional operation on this sentence
If yes, let him choose another operation.
If no, ask the user if he wants to enter a new sentence.
-If yes, display the menu from beginning and ask him to enter a new
sentence
#include <stdio.h>
#include <stdlib.h>
int main()
{
char sentence[30];
int operation;
char *ptr;
printf ("\n\n USER MENU...\n\n\n");
printf ("1 - Press Number 1 to Separate sentence into tokens.\n\n");
printf ("2 - Press Number 2 to get the frequency of each word.\n\n");
printf ("3 - Press Number 3 to display the corresponding meaning, from the dictionary.\n\n\n");
printf("Enter The Sentence First ....\n\n ");
gets(sentence);
printf ("\n\n");
printf ("Choose the operation you want from USER MENU...\n\n");
scanf ("%d",&operation);
printf ("\n");
switch (operation)
{
case 1:
ptr = strtok (sentence," .");
while (ptr != NULL)
{
printf ("%s\n",ptr);
ptr = strtok (NULL, " .");
}
break;
}
return 0;
}
Sorry for long comment
---------- Post updated at 09:22 AM ---------- Previous update was at 09:19 AM ----------
I have asked many which language to learn first , they told me to learn C firstly