I have this code but when I run the program it displays the first two cout lines without prompting the cin after I make choice==1. I'm sure my mistake is very simple and dumb, but I can't figure it out for some reason, please help!
int main() {
string School, Team, Conference;
string inputSchool, inputTeam, inputConf, inputRecord;
string searchSchool;
char confirm;
int choice, wins, losses;
string input = "";
string textFile = "BBall.txt";
ifstream iFile;
do{
system("CLS");
cout << "Please enter the choice you wish to continue with:\n";
cout << "1 - Insert a node.\n";
cout << "2 - Search for a node.\n";
cout << "3 - Exit the program.\n\n";
cin >> choice;
if(choice == 1) {
cout << "Please enter the name of the school you wish to add.\n";
getline( cin, inputSchool);
cout << "Please enter the Team Name.\n";
getline( cin, inputTeam);
//cin >> inputTeam;
cout << "Please enter the team's record (Seperated by a space).\n";
cin >> wins >> losses;
//cin >> inputRecord;
cout << "Please enter this school's conference.\n";
getline( cin, inputConf);
//cin >> inputConf;
}
first off bro if you wanna type this without typing std al the time add using namespace std; and anohte thing ou didnt even declare your libraries you need to add an iostream library for sure then after that you ay need a few others too. so the beginnig of your code should actally look like this:
#include <iostream> // this is your libraries.
using namespace std; //this is so you dont have to constantly type std::
int main();
those two top things are mainly what i see is wrong im sure you may know what those were at the top but i added side notes to kinda help declare incase you didnt
@ l B: Ehh it's not that I'm encourageing it infanct it can be faulty but it does save time sometimes if you know exactly what your writing and what goes where, but down to the point if bbesase didn't want to go through and add std:: for the cout and cin it would possibly help on saving time.
It is a bad habit. Just because it doesn't hurt now doesn't mean it will not hurt later. Procrastination and short-sightedness should not be encouraged, ever ;)