My code below has one issue, it works but when I run it, it displays
'Code 0: Code 1:'
I'm expecting
'Code 0:' then waits for your first input and then next is 'Code 1:'
Here is my code:
using namespace std;
//function Definitions
int fStore();
void fPrint();
//global variable definitions
map <int, string> codeDB; //map for inputStrings
string inputData; //store long string here
string status("EXIT");
int lineNum;
int main(){
int choice;
//menu here
cin >> choice;
switch(choice){
case 1: fStore(); break;
case 2: fPrint(); break;
case 3: cout << "You chose third" << endl; break;
default: cout << "Invalid Input" << endl;
}
}
int fStore(){
cout << "\n----------Input your codes here-----------\n" << endl;
while (inputData.compare(status)){
cout << "Code " << lineNum << ": ";
getline(cin, inputData);
codeDB.insert(pair<int, string>(lineNum, inputData));
lineNum++;
}
inputData = "";
main();
}
I'm pretty sure I'm just missing something here.