Question: Task A: Dictionary using Arrays A regular dictionary contains the words and the definitions. In addition to the words and the definitions, we will also

Task A: Dictionary using Arrays

A regular dictionary contains the words and the definitions. In addition to the words and the definitions, we will also store the part-of-speech (pos). The words, definitions and pos are going to be stored in Arrays. Use these global-variables in your code outside main() function:

const int g_MAX_WORDS = 1000; int g_word_count = 0; string g_words[g_MAX_WORDS]; string g_definitions[g_MAX_WORDS]; string g_pos[g_MAX_WORDS]; 

Create a C++ file and add the following function:

/* @param : The string with the `filename` @post : Reads the words, definitions pos into the global-arrays and set the value of `g_word_count` to the number of words read */ void readWords(string filename); 

Heres an example text file:

WORD POS : DEFINITION Grumpy Adjective : bad-tempered and irritable Professor Noun : a teacher of the highest rank in a college or university Does Verb : perform (an action, often of unspecified nature) Nothing Adverb : not at all 

Example:

Calling readWords() on the above text file will modify the global variables like this:

g_MAX_WORDS: 1000 g_word_count: 5 g_words: ["WORD", "Grumpy", "Professor", "Does", "Nothing"] g_pos: ["POS", "Adjective", "Noun", "Verb", "Adverb"] g_definitions: [ "DEFINITION", "bad-tempered and irritable", "a teacher of the highest rank in a college or university", "perform (an action, often of unspecified nature)", "not at all" ] 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!