Quick c++ Help

Associate
Joined
4 Dec 2007
Posts
103
Hey Everyone..

Right, Doing a little Tutorial for UNI, only just started c++. I have to create an Array that basically shows the Free and Taken seats in a coach.

Right, so F would indicate Free and N would indicate Not free. so far i've gotten:

char p[3];



p[0] = "F";


p[1] = "F";


p[2] = "N";

cout<< p;


Thing is, its having none of it in compiling. I tried it with INT's, it worked, but the numbers were displayed in HEX and i couldt get my head around it.

Now i tried to create 2 arrays so it would show

Seat Avail

1 F
2 F
3 N

But all the online books i been reading have many different formats in what to include which i dont have etc.

How do i go about doing it :(

Michael
 
Wooo it worked, Thanks man. I rustled around with it again and i got it to work it was only the single quotation i wasn't including :(

This is what i got so far..

//My array being set up

char Seats[10] = {'F', 'F', 'F', 'N', 'N', 'F', 'N', 'F', 'F', 'N'};


cout<<"Legend: F = FREE SEAT N=NOT FREE\n\n";

cout <<"\nSeat" <<" Free?\n\n";


for (int i = 1; i < 10; i++)

cout<< i <<" ---- "<< Seats <<endl <<endl;

Now... Is it possible, when my program is running, to lets say, change a F to a N and Vice Versa. Would the way i've written the array allow me to be able to change the contents in Seats in the program to F or N. So lets say i make a booking on the program, then the user wants to seat in a Free seat .. Seat 1... Can i change it to show N then?
 
I have i starting at 1 because i cant book seat 0 lol

I don't get your code though... I got this when run..



Like is there a way , like i have a method to book seats, there a way i could
basically show the seats then i get a cin>> prompt to choose which seat you want to book (Choose a F) one and then re-display the array and show the F has now been changed to N.
 
Thanks, ill give it a go now, ill change the increment for the i++ to ++i too. Ill see how i can tackle it :)

**edit** Im a bit confused on the go ahead on doing it :$
 
Last edited:
Ok im a failure, it's not having none of it :|

This is what i've got at the moment :

cout<<"\n\n\n\nWelcome to Checking the booking...\n";
cout<<"----------------------------------\n\n\n\n";

//My array being set up with Free and Not free Values

char Seats[10] = {'F', 'F', 'F', 'N', 'N', 'F', 'N', 'F', 'F', 'N'};


cout<<"Legend: F = FREE SEAT N=NOT FREE\n\n";

cout <<"\nSeat" <<" Free?\n\n";


for (int i = 1; i < 10; i++)

cout<< i <<" ----- "<< Seats <<"\n\n";


}

What i tried to do was, see if i could Change the value. I suggest it would be something like " If seat[?] selected then change to Y else N." right? But how do i do the code to which ever the user enters as the seat to change :( . 5 hours left till submission :(
 
Last edited:
Back
Top Bottom