I'm pretty new to C++. I keep getting this issue when I try to use switch.
1 2 3 4 5 6 7 8 9 10 11 12 13
cout<<"Enter 1 to enter student info, 2 to view student info, 3 to add course.";
cin>>choice;
switch(choice)
{
case 1://enter student info
cout<<"\nEnter First Name: ";
cin.getline(s.firstName, 64);
cout<<"\nEnter Middle Name: ";
cin.getline(s.midName, 64);
cout<<"\nEnter Last Name: ";
cin.getline(s.lastName, 64);
break;
Whenever I test it and press 1 (choice is int by the way) then enter, the output is
1 2 3 4
Enter 1 to enter student info, 2 to view student info, 3 to add course.1
Enter First Name:
Enter Middle Name:
So, it is as if when I press enter after I press 1 that it also acts as if I pushed enter when I'm prompted to enter the first name. Why does it seem to register that I press enter twice?
I'm using Code::Blocks 10.05. Thanks!