I can't input the names i need. I declared as a char nam[34];
and after the first name the program terminates.
Code:#include <iostream.h> #include <string.h> #include <iomanip.h> int main() { // declare variables int hold; int passenger; char nam[34]; int smoke; // get input for (passenger = 0; passenger <=20; passenger++) { cout << "Enter your name : "; cin >> nam[34]; cout << "Smoking on plane 1)Yes or 2) No" << endl; cout << "Make a choice :"; cin >> smoke; } // switch statement switch (smoke) { case 1: cout << "Please sit in back of the plane on seats 15-20 " << endl; break; case 2: cout << "Please sit on seats 1-14 and please don't smoke." << endl; break; default: cout << "Seats are filled. Sorry." << endl; break; } // print boarding tickets cin >> hold; return 0; }



LinkBack URL
About LinkBacks


