-1

This is part of a cinema project code that my friend did. I understand most of the other parts, but when I came to this part, I am completely lost.
Can someone please explain this to me line by line please.

Thank You.

If you need the complete code to understand ,I'll upload it....

void Ticketing::ChooseSeat(int NumOfSeat,double sale)
{
    char Option[256]={0};
    string Input="";
    char SeatY[1];
    int SeatX;
    int FinalSeatY=0;
    char CInput[256]={0};
    cout << "\nChoose Seat : ";
    getline (cin,Input);
    for (int i=0;i<Input.size();i++)CInput[i]=Input[i];
    cout << "Action('o' for reserved and 'x' for direct payment) : ";
    getline (cin,Input);
    for (int i=0;i<Input.size();i++)Option[i]=Input[i];
    sscanf ( CInput, "%c %d",SeatY , &SeatX);//http://www.cplusplus.com/reference/clibrary/cstdio/sscanf/
    SeatY[0]=toupper(SeatY[0]);
    Option[0]=toupper(Option[0]);
    FinalSeatY = int(SeatY[0]-65);//get integer value of a char to goto array's y index
    int temp = NumOfSeat+SeatX;
    for (;SeatX<temp;SeatX++)
    {
        seat[SeatX-1][FinalSeatY] = Option[0];
    }
    if (Option[0]=='X')UpdateCash(NumOfSeat,sale);
}
Votes + Comments
Not clear!
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by WaltP
0

Tell you what. You explain as best you can what each line does, and we can help you correct your assumptions.

The biggest problem with this code is the structure.
-- No whitespace to make things easier to read.
-- Lines that do too much and should be broken into multiple lines ( for statements)

Add some formatting and comment each line then repost the code.
And don't parrot the line in your comment, for example: a = 3 // put 3 in variable a Why is a 3 being put in a?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.