473,387 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

The Problem is on my 'int main( )' what do you suggest???

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <cctype>
  3. #include <string>
  4. #include <cstring>
  5. using namespace std;
  6.  
  7.  
  8. int assignSeat(int seat_num, int row_num, int pass_num);
  9. int num1(char*);
  10. int num2(char*);
  11.  
  12. int NumSeats = 200;
  13.  
  14. void InitializeSeats();
  15. void Reserve();
  16. void Cancel();
  17. void ChangeSeat();
  18. void Display();
  19.  
  20. struct Seat
  21.   {
  22.       char pass_name[80];
  23.       int Available;
  24.   };
  25.  
  26.   struct Seat SeatArray[10][20];
  27.  
  28. int main()
  29. {      
  30.    char seatchioce = 0;
  31.    int row_num = 20;
  32.    char a = 0;
  33.    char w = 0;
  34.  
  35.   int total_passenger = 12;
  36.  
  37.   char arr1[][20] = {"1A","2A","3A","4A","5A","6A","7A","8A","9A", "10A","11A","12A","13A","14A","15A","16A","17A","18A","19A",""20A"};
  38.   char arr2[][20] = {"1B","2B","3B","4B","5B","6B","7B","8B","9B", "10B","11B","12B","13B","14B","15B","16B","17B","18B","19B",""20B"};
  39.   char arr3[][20] = {"1C","2C","3C","4C","5C","6C","7C","8C","9C", "10C","11C","12C","13C","14C","15C","16C","17C","18C","19C",""20C"};  
  40.   char arr4[][20] = {"1D","2D","3D","4D","5D","6D","7D","8D","9D", "10D","11D","12D","13D","14D","15D","16D","17D","18D","19D",""20D"};  
  41.   char arr5[][20] = {"1E","2E","3E","4E","5E","6E","7E","8E","9E", "10E","11E","12E","13E","14E","15E","16E","17E","18E","19E",""20E"}; 
  42.   char arr6[][20] = {"1F","2F","3F","4F","5F","6F","7F","8F","9F", "10F","11F","12F","13F","14F","15F","16F","17F","18F","19F",""20F"};   
  43.   char arr7[][20] = {"1G","2G","3G","4G","5G","6G","7G","8G","9G", "10G","11G","12G","13G","14G","15G","16G","17G","18G","19G",""20G"};  
  44.   char arr8[][20] = {"1H","2H","3H","4H","5H","6H","7H","8H","9H", "10H","11H","12H","13H","14H","15H","16H","17H","18H","19H",""20H"};  
  45.   char arr9[][20] = {"1I","2I","3I","4I","5I","6I","7I","8I","9I", "10I","11I","12I","13I","14I","15I","16I","17I","18I","19I",""20I"};  
  46.   char arr10[][20] = {"1J","2J","3J","4J","5J","6J","7J","8J","9J", "10J","11J","12J","13J","14J","15J","16J","17J","18J","19J",""20J"};  
  47.   int MenuChoice;
  48.  
  49.   InitializeSeats();
  50.   while(1)
  51.   {
  52.       cout << " 1. Reserve" << endl;
  53.       cout << " 2. Cancel" << endl;
  54.       cout << " 3. Change Seat" << endl;
  55.       cout << " 4. Display" << endl;
  56.       cout << " 5. Exit" << endl;
  57.  
  58.       cout << "Enter your choice: ";
  59.       cin >> MenuChoice;
  60.  
  61.     if((MenuChoice < 0) && (MenuChoice > 5))
  62.     {
  63.       cout << "Invalid Choice" << endl;
  64.       system("Pause Try Again");
  65.     }
  66.     else
  67.     {
  68.         switch(MenuChoice)
  69.         {
  70.             case 1: Reserve();
  71.                 break;
  72.             case 2: Cancel();
  73.                 break;
  74.             case 3: ChangeSeat();
  75.                 break;
  76.             case 4: Display();
  77.                 break;
  78.             case 5:
  79.                 exit(1);
  80.         }
  81.     }
  82.     cin.get();  
  83.   }
  84.  
  85. return 0;
  86.  
  87. }
  88. void Reserve() 
  89. {
  90.     int pass_num = 0;
  91.  
  92.     cout << "Wellcome to Brofar Airline Passenger seat reservation" << endl;
  93.  
  94.      cout << "All " << NumSeats << " seats are available " << endl;
  95.  
  96.      for(int i = 0; i < 10; i++)
  97.      {
  98.          for(int j = 0; j < 20; j++)
  99.          {
  100.              if(SeatArray[i][j].Available == 1)
  101.              {
  102.                  cout << "Please enter the passenger name: ";
  103.                  cin >> SeatArray[i][j].pass_name;
  104.                  SeatArray[i][j].Available = 0;
  105.                  NumSeats--;
  106.                  return;
  107.              }
  108.          }
  109.  
  110.      }
  111. }
  112. void Cancel()
  113. {
  114.     char CancelPassengerName[80];
  115.  
  116.     cout << "Enter the Passenger to be cancelled: ";
  117.     cin >> CancelPassengerName;
  118.     for(int i =0; i <10; i++)
  119.     {
  120.         for(int j=0; j<20; j++)
  121.         {
  122.  
  123.             if(strcmp(SeatArray[i][j].pass_name, CancelPassengerName) == 0)
  124.             {
  125.                 NumSeats++;
  126.                 SeatArray[i][j].Available = 1;
  127.                 return;
  128.             }
  129.         }
  130.     }
  131.     cout << " Passenger not in the list" << endl;
  132. }
  133. void ChangeSeat()
  134. {
  135.     char MovePassenger[80];
  136.     int SeatRow, SeatColumn;
  137.  
  138.     cout << "Enter the passenger name to be moved: ";
  139.     cin >> MovePassenger;
  140.  
  141.     for(int i = 0; i < 10; i++)
  142.     {    for(int j = 0; j < 20; j++)
  143.         {
  144.             if(strcmp(SeatArray[i][j].pass_name, MovePassenger) == 0)
  145.             {
  146.                 SeatRow = i;
  147.                 SeatColumn = j;
  148.             }
  149.         }
  150.     }
  151.  
  152.     if(NumSeats <= 0)
  153.     {
  154.         cout << "No seat available there for you cannot change seat" << endl;
  155.         return;
  156.     }
  157.     else{
  158.         for(int i = 0; i < 10; i++)
  159.         {
  160.             for(int j = 0; j < 20; j++)
  161.             {
  162.                 if(SeatArray[i][j].Available == 1)
  163.                 {
  164.                     strcpy_s(SeatArray[i][j].pass_name, MovePassenger);
  165.                     SeatArray[SeatRow][SeatColumn].Available = 1;
  166.                     SeatArray[i][j].Available = 0;
  167.  
  168.                     return;
  169.                 }
  170.             }
  171.         }
  172.     }
  173. }
  174. void Display()
  175. {
  176.     for(int i = 0; i < 10; i++)
  177.     {
  178.         for(int j = 0; j < 20; j++)
  179.         {
  180.             if(SeatArray[i][j].Available == 0)
  181.             {
  182.                 cout << SeatArray[i][j].pass_name << " = " << i+1;
  183.                                 if (j == 0) { cout << "A" << endl; }
  184.                                 else { cout << "B" << endl; }
  185.             }
  186.             else
  187.             {
  188.                 if(j == 1)
  189.                     cout << i+1 << "B" << endl;
  190.                 else
  191.                     cout << i+1 << "A" << endl;
  192.             }
  193.         }
  194.     }
  195. }
  196.  
  197. void InitializeSeats()//Initialy all seats are available
  198. {
  199.     for(int i = 0; i < 30; i++)
  200.     {
  201.         for(int j = 0; j < 2; j++)
  202.             SeatArray[i][j].Available = 1;
  203.     }
  204. }
Dec 8 '09 #1
5 2030
mac11
256 100+
What sort of help do you need? Are you trying to compile this code and get errors or does it compile but not do what you want?
Dec 8 '09 #2
i have already compiled it... but then i get 61 errors just on my int main... i dont get my problem there.. it says here...

syntax error : 'bad suffix on number'
syntax error : 'constant'
newline in constant
syntax error : missing ';' before '{'
syntax error : 'bad suffix on number'
syntax error : missing ';' before 'constant'
newline in constant
syntax error : missing ';' before identifier 'B'
'B' : undeclared identifier
syntax error : missing ';' before 'string'
syntax error : missing ';' before type 'char'

and so on and so forth....
Dec 8 '09 #3
RedSon
5,000 Expert 4TB
I would double check the declaration of all your arrays first.
Dec 8 '09 #4
Frinavale
9,735 Expert Mod 8TB
In the future could you please only post the code that is relevant to the problem. It's unfair to expect people to sift through tons of code to find the few lines that you are having problems with.

Also, in the future, please specify what you are having problems with, what (if any) errors you are getting, and what you have tried to solve the problem. Don't just post a bunch of code and expect us to figure out what it is, what's wrong with it, and what you are having problems with.

Please check out the posting guidelines for more information on how to ask a question.

You have a whole bunch of 2D arrays declared.
Are you sure that you are doing this correctly?

**edit: haha looks like RedSon beat me to it**

-Frinny
Dec 8 '09 #5
RedSon
5,000 Expert 4TB
I would also examine this line of code:

struct Seat SeatArray[10][20];

Further, feel free to post your error messages in their entirety.

edit: Looks like frin and I are having edit wars! :P
Dec 8 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

19
by: Steven T. Hatton | last post by:
The short sample program listed below has some features that I find to be bad style. In particular, they fail to communicate the connection between names used in this program and the location in...
30
by: JKop | last post by:
When you want to store an integer in C++, you use an integral type, eg. int main() { unsigned char amount_legs_dog = 4; } In writing portable C++ code, there should be only two factors that...
28
by: Richard Cavell | last post by:
Hi, Is there some kind of canonical list, or would someone like to give a brief rundown, as to: sizeof(int) sizeof(long int) sizeof(long long) etc
4
by: Vinu | last post by:
hi How can i accept unicode char in command line. The application on Solaris Sparc expects wide characters for its processing Can you suggest standard way of doing it on Sun Solaris Sparc? We...
13
by: Sokar | last post by:
I have my main function set up as int main(int argv, char *argv) so taht i can read in a variable which is passed to the program on the command line. The problem is that main calls other...
4
by: lada77 | last post by:
All, Just wondering if one of you very helpful guru's out there could comment on some odd behaviour I am seeing. I'm betting it is something obvious but I am not experienced enough to tell...
4
by: pms | last post by:
Need suggestions to improve this program. using System; namespace CalculateWage { class GetEmployeeDetails {
34
by: Davy | last post by:
Hi all, I am writing a function, which return the pointer of the int. But it seems to be wrong. Any suggestion? int * get_p_t(int t) { return &t; } int main()
10
by: kishore84 | last post by:
Hi all, This might be a small query but imp for me. I have put my ideas in comments in below prog. My idea is if i am assigning memory for one int how can i store there 10 elements of int. Is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.