//////////////////////////////////////////////////////////////////////////////////
// ASK FOR CUSTOMERS NAME
//////////////////////////////////////////////////////////////////////////////////
string custOrder;
string custName;
string custId;
cout << "\t\tHello, What is your Name? ";
cin.ignore();
getline(cin,custName);
system("CLS");
//////////////////////////////////////////////////////////////////////////////////
// ASKS HOW MUCH GAS THEIR SPACECRAFT NEEDS AND FOR ID
//////////////////////////////////////////////////////////////////////////////////
cout << "Would you like a Full Tank for your Space Cruiser X, " << custName << "? ";
cin.ignore();
getline(cin,custOrder);
//////////////////////////////////////////////////////////////////////////////////
// KEY TESTING
//////////////////////////////////////////////////////////////////////////////////
if(custOrder[0] == 'y')
cout << "1\n\n";
if(custOrder[0] != 'y')
cout << "0\n\n";
cout << "\n\nDo you Have your Space ID? ";
if(custId[0] == 'y')
cout << "\n\nOk, your car will be ready in 1 sec.\nThanks for Choosing Sapce Filler!\n\n";
if(custId[0] != 'y')
cout << "\n\nSorry, I cannot help you then, its store Policy.\n\n";
///////////////////////////////////////////////////////////////////////////////////
// EXIT
///////////////////////////////////////////////////////////////////////////////////
system("PAUSE");
return 0;
Cin Help Needed!
Hello,
I've been focusing on school work for the past week or two, so i havent been able to program for the past week or so. I started making this little program, just to get a little practice, and it doesnt seem to work right. It takes the first letter off every input the user enters, which throws off everything. Any help is appreciated.
ignore() tells the program to ignore a character of input. So, you're basically telling the program to ignore a character of input and then get the rest of what the user input.
So, get rid of the ignore(). You probably won't need it at all because getline grabs the newline as well.
So, get rid of the ignore(). You probably won't need it at all because getline grabs the newline as well.
Also note that you haven't actually read in to custId.
And what on earth has happened with your indentation? o_O
And what on earth has happened with your indentation? o_O
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement