473,386 Members | 1,734 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,386 software developers and data experts.

0 errors but no output.. any advice??

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 = 10;
  32.    char a = 0;
  33.    char w = 0;
  34.  
  35.   int total_passenger = 12;
  36.  
  37.   int arr1[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
  38.   int arr2[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
  39.   int arr3[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
  40.   int arr4[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
  41.   int arr5[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
  42.   int arr6[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
  43.   int arr7[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
  44.   int arr8[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
  45.   int arr9[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
  46.   int arr10[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
  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.                     strcmp(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 < 200; i++)
  200.     {
  201.         for(int j = 0; j < 2; j++)
  202.             SeatArray[i][j].Available = 1;
  203.     }
  204. }
Dec 11 '09 #1
2 1679
gpraghuram
1,275 Expert 1GB
Hi,
You have defined the SeatArray like this struct Seat SeatArray[10][20];
and you are initializing it till 200...How it will work and this will surely crash.

thanks
Raghu
Dec 11 '09 #2
Banfa
9,065 Expert Mod 8TB
My guess is that when you run the program you immediately enter menu option 5 and exit it and it correctly prints nothing.


OK a bit facetious but my point is that you have made no attempt to describe what you entered into the program and what you expected the program to do. All you have done is given the result and that result is actually valid for given program inputs.

Please describe the problem in more detail.
Dec 11 '09 #3

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

Similar topics

5
by: steve | last post by:
Hi, In my script (phpnuke), whenever there is access to database, there is this line of code: message_die(GENERAL_ERROR, ’some error msg’, ’’, __LINE__, __FILE__, $sql); Is there a more...
0
by: Rolf Kemper | last post by:
Dear All, I'm facing the problem below and need some advice/help on it. I'm loading various XML files via the document function into my XSLT. As long all files exist, it's fine. But when a...
2
by: Angus | last post by:
Hello I am using some classes from a third party and have included them in my projecxt and am compiling and linking with them. Everything compiles ok but I get these link errors: I added...
13
by: kolmogolov | last post by:
/* Hi, I have removed things irrelevant to reproducing the problem. What's wrong with my code? Thanks in advance for any hint! 1166425362 */ #include <stdio.h> #include <stdlib.h> #include...
28
by: Neo Geshel | last post by:
NOTE: PAST EXPERIENCE HAS SHOWN ME THAT MANY ON USENET FAIL TO READ ARTICLES PROPERLY PRIOR TO ANSWERING. I AM LOOKING FOR VERY SPECIFIC INFORMATION, THEREFORE PLEASE READ AND UNDERSTAND...
7
by: mohammaditraders | last post by:
Write a program which overloads a binary Minus (+) operator, The program will contain a class Matrix, This class will contain a private data member Array which store int values. The class will...
11
by: Mark Space | last post by:
Hi all. I have a new PHP install. I've got php.info() running for the web browser and it returns everything it should. Great! Except a couple of small things are wrong. php.info() says that...
3
by: Michael Sharman | last post by:
Hi guys, I'm somewhat new to PHP, so please excuse what I hope is an easy question. I've experienced some issues lately where the code on my development environment throws no errors, but when...
7
by: Twayne | last post by:
HI, Below is fully functional, non-functional code :^): In other words, it works, but it doesn't do anything and darned if I can see why. None of the 3 $email assignments result in any output....
0
by: fenners | last post by:
Hi new to programming VBA in Access 2003. I have a form which has two comboboxes. The first combobox uses the folowing rowsource. SELECT Outputs_Classification.Output_id,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.