Thread: I want to show full name in the following code my it shows only the fisrt chracter

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    22

    Question I want to show full name in the following code my it shows only the fisrt chracter

    what should be the correct code so that it would show the complete name
    Code:
    #include<conio.h>#include<iostream.h>
    class air_line
    {
    private:
    char name[5][100];
    long double opt,cnic[5],ticket_number[5],ticket_number1;
    int opt1,seat_type;
    public:
    void phool_bootey_start()
    {
    cout<<"================================================================================";
    cout<<"\t\t\tWelcome to Google Airlines \n";
    cout<<"================================================================================";
    }
    void input()
    
    
    {
    for(int i=1;i<=5;i++)
    {
    cout<<"\n";
    cout<<"Please Enter Your Name : ";
    getchar(name[i]);
    cout<<"Please Enter Your CNIC Number : ";
    cin>>cnic[i];
    cout<<"Please Enter Your Ticket Number : ";
    cin>>ticket_number[i];
    }
    }
    void process()
    {
    cout<<"Enter your option  \n 1.Fare  \n 2.Ticket Confirmation \n ";
    cin>>opt;
    if(opt==1)
    {
    cout<<"\nSelect Journey \n 1.Pakistan\n 2.Abroad \n";
    cin>>opt1;
    switch(opt1)
    {
    case 1:
    cout<<"\nSelect Seat Type \n1.Economy\n2.Business\n3.Upper Business\n";
    cin>>seat_type;
    if(seat_type==1)
    {
    cout<<"\n********************** FARES FOR PAKISTAN 09 JUNE 2013 ************************";
    cout<<"\n\n ";
    cout<<"Departure \t Timings\t Arrival \t Timings \t Fare \n ";
    cout<<"\n Islmabad \t 05:00 AM \t Lahore \t 05:30 AM \t 10500 PKR";
    cout<<"\n Islmabad \t 09:00 AM \t Karachi \t 11:30 AM \t 20000 PKR";
    cout<<"\n Islmabad \t 01:00 PM \t Peshawar \t 02:30 PM \t 10000 PKR";
    cout<<"\n Islmabad \t 05:00 PM \t Quetta \t 07:00 PM \t 25000 PKR";
    cout<<"\n Islmabad \t 11:00 PM \t Sialkot \t 12:30 PM \t 55000 PKR ";
    }
    if(seat_type==2)
    {
    cout<<"\n********************** FARES FOR PAKISTAN 09 JUNE 2013 ************************";
    cout<<"\n\n ";
    cout<<"Departure \t Timings\t Arrival \t Timings \t Fare \n ";
    cout<<"\n Islmabad \t 05:00 AM \t Lahore \t 05:30 AM \t 12100 PKR";
    cout<<"\n Islmabad \t 09:00 AM \t Karachi \t 11:30 AM \t 30000 PKR";
    cout<<"\n Islmabad \t 01:00 PM \t Peshawar \t 02:30 PM \t 20000 PKR";
    cout<<"\n Islmabad \t 05:00 PM \t Quetta \t 07:00 PM \t 35000 PKR";
    cout<<"\n Islmabad \t 11:00 PM \t Sialkot \t 12:30 PM \t 45000 PKR ";
    }
    if(seat_type==3)
    {
    cout<<"\n********************** FARES FOR PAKISTAN 09 JUNE 2013 ************************";
    cout<<"\n\n ";
    cout<<"Departure \t Timings\t Arrival \t Timings \t Fare \n ";
    cout<<"\n Islmabad \t 05:00 AM \t Lahore \t 05:30 AM \t 20500 PKR";
    cout<<"\n Islmabad \t 09:00 AM \t Karachi \t 11:30 AM \t 40000 PKR";
    cout<<"\n Islmabad \t 01:00 PM \t Peshawar \t 02:30 PM \t 50000 PKR";
    cout<<"\n Islmabad \t 05:00 PM \t Quetta \t 07:00 PM \t 65000 PKR";
    cout<<"\n Islmabad \t 11:00 PM \t Sialkot \t 12:30 PM \t 75000 PKR ";
    }
    break;
    case 2:
    cout<<"\nSelect Seat Type \n1.Economy\n2.Business\n3.Upper Business\n";
    cin>>seat_type;
    if(seat_type==1)
    {
    cout<<"\n*********************** Fares FOR ABROAD 09 JUNE 2013 *************************";
    cout<<"\n\n ";
    cout<<"Departure \t Timings\t Arrival \t Timings \t Fare \n ";
    cout<"Islmabad \t 05:00 AM \t Dubai UAE \t 24000 PKR";
    cout<<"\n Islmabad \t 09:00 AM \t Wishington \t 03:00 PM \t 70000 PKR";
    cout<<"\n Islmabad \t 01:00 PM \t California \t 01:00 AM \t 82000 PKR";
    cout<<"\n Islmabad \t 05:00 PM \t Beijing \t 08:00 PM \t 30000 PKR";
    cout<<"\n Islmabad \t 11:00 PM \t Tehran \t 04:00 PM \t 17000 PKR ";
    }
    if(seat_type==2)
    {
    cout<<"\n*********************** Fares FOR ABROAD 09 JUNE 2013 *************************";
    cout<<"\n\n ";
    cout<<"Departure \t Timings\t Arrival \t Timings \t Fare \n ";
    cout<"Islmabad \t 05:00 AM \t Dubai UAE \t 34000 PKR";
    cout<<"\n Islmabad \t 09:00 AM \t Wishington \t 03:00 PM \t 40000 PKR";
    cout<<"\n Islmabad \t 01:00 PM \t California \t 01:00 AM \t 52000 PKR";
    cout<<"\n Islmabad \t 05:00 PM \t Beijing \t 08:00 PM \t 50000 PKR";
    cout<<"\n Islmabad \t 11:00 PM \t Tehran \t 04:00 PM \t 67000 PKR ";
    }
    if(seat_type==3)
    {
    cout<<"\n*********************** Fares FOR ABROAD 09 JUNE 2013 *************************";
    cout<<"\n\n ";
    cout<<"Departure \t Timings\t Arrival \t Timings \t Fare \n ";
    cout<"Islmabad \t 05:00 AM \t Dubai UAE \t 24000 PKR";
    cout<<"\n Islmabad \t 09:00 AM \t Wishington \t 03:00 PM \t 90000 PKR";
    cout<<"\n Islmabad \t 01:00 PM \t California \t 01:00 AM \t 92000 PKR";
    cout<<"\n Islmabad \t 05:00 PM \t Beijing \t 08:00 PM \t 90000 PKR";
    cout<<"\n Islmabad \t 11:00 PM \t Tehran \t 04:00 PM \t 99000 PKR ";
    }
    break;
    default:
    cout<<"Wrong Statement Entered";
    }
    }
    else if(opt==2)
    {
    cout<<"\n Please Enter Your Ticket Number : ";
    cin>>ticket_number1;
    
    
    for (int i=1;i<=5;i++)
    {
    if(ticket_number1==ticket_number[i])
    {
    cout<<"\n Your Seat is Confirmed ";
    cout<<"\n Name of Passenger is: "<<putchar[i];
    cout<<"\n CNIC No. :"<<cnic[i];
    }
    }}
    else
    cout<<"Wrong Statement Entered";
    }
    void phool_bootey_end()
    {
    cout<<"\n\n================================================================================";
    cout<<"\t:)Thanks for Visiting Google Airlines - Have a Safe Journey :)\n";
    cout<<"================================================================================";
    }
    };
    main()
    {
    clrscr();
    air_line tahir;
    tahir.phool_bootey_start();
    tahir.input();
    tahir.process();
    tahir.phool_bootey_end();
    getch();
    }

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    you haven't followed any of the advice from the 3 other threads you posted. why should anyone help you when you won't accept the help?

    in any case, what makes you think that you will get a whole name when you're only accepting one character of input from the user? even if you were accepting the whole name, what makes you think the whole thing would be printed when you're only telling the computer to print one character?
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,665
    > for(int i=1;i<=5;i++)
    Please explain to us why you think this is correct?

    If your basis of correctness is "well, it doesn't crash, so I'll ignore anyone who mentions it", then you're in for a very rough time.

    Today it might be working for you, but sooner or later, you're just going to get your ass handed to you on a plate.

    So either give up programming, or learn to read all the many fine posts telling you what is WRONG with your code.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. only one thread shows on openMP code inside
    By mariola82 in forum C++ Programming
    Replies: 2
    Last Post: 07-15-2011, 08:35 AM
  2. Watching for a control chracter
    By iain in forum Linux Programming
    Replies: 8
    Last Post: 11-27-2004, 11:14 AM
  3. Char Array collecting position of an indivudal chracter.
    By explosive in forum C++ Programming
    Replies: 8
    Last Post: 05-01-2004, 01:37 AM
  4. a code to filter full path
    By hanhao in forum C++ Programming
    Replies: 3
    Last Post: 03-07-2004, 08:28 AM
  5. re:array of notation (full code)
    By lcpongkl in forum C Programming
    Replies: 2
    Last Post: 04-08-2003, 06:15 AM