I am trying to create a database where the user can input certain data to be stored in a csv file. This is a console based application as im a beginner. I have a switch statement which is used to direct the user to a function based on their choice. The switch statement works well but when the addingdata() function gets called:
{
ofstream newData;
newData.open("TreeDatabase.csv", ios::app);
cout << "Enter tree species: " << endl;
getline(cin, treeSpecies);
cout << "Enter tree name: " << endl;
getline(cin, treeName);
return 0;
}
All the cout statements seem to get called at once without waiting for the user input whereas in the main() function, the user input is taken in first before moving onto the next cout statement. Why is this?