Comment down for any queries
Please give a thumb up
Code:
#include <bits/stdc++.h>
using namespace std;
void readEntries(string *words, string *meanings, int
directorySize) {
for(int i = 0; i < directorySize; i++) {
// 2.a Ask for the word
cout << "Enter Term "<<i+1<<": ";
// 2.c Store the word in array
getline(cin,words[i]);
// 2.b Ask for the definition
cout << "Enter the definition for " <<
words[i]<<": ";
// 2.d Store the definition in array
getline(cin,meanings[i]);
}
}
void writeEntries(string *words, string *meanings, int
directorySize) {
// 3. Output entries which were stored
cout << endl << "You entered: " << endl;
for(int i = 0; i < directorySize; i++) {
cout <<i+1<<". "<< words[i] << ": "
<< meanings[i] << endl;
}
}
int main() {
int directorySize;
// 1. Ask the user for directory size
cout << "How Many terms do you want the directory to hold?
";
cin >> directorySize;
string ln;
getline(cin,ln);
// Initialize arrays
string *words = new string[directorySize];
string *meanings = new string[directorySize];
//Read user input
readEntries(words, meanings, directorySize);
//Print user input
writeEntries(words, meanings, directorySize);
// 4. Clear memory
delete words;
delete meanings;
}
Output and compilation:
Comment down for any queries
Please give a thumb up
in c++ sample output Description A dictionary is a collection of words that contain at least...