Having a little trouble understanding why this will not work.
Basically i have 3 cout and 3 cin's and after i enter the first one it skips the last two and doesnt let me enter anything.
Here is the code:
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int name;
int seats;
int totalseats;
float cost = 4.23456;
float totalcost = 4.23456;
{
cout << "Please enter your name: " << endl;
cin >> name;
cout << "Please enter the amount of seats you require: " << endl;
cin >> seats;
cout << "Please enter the cost per seat: " << endl;
cin >> cost;
}
return 0;
}
Basically all it is doing is inputting the name and then coming straight up with the last two couts and not asking me to input there values.
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
//int name;
string name ; // name is a string ( #include <string> )
int seats;
float cost = 4.23456;
{
cout << "Please enter your name: " ;
//cin >> name ; // read a name containing no white spaces
std::getline( cin, name ) ; // read one complete line as the name
cout << "Please enter the amount of seats you require: " ;
cin >> seats ;
cout << "Please enter the cost per seat: " ;
cin >> cost;
}
// ...
}