473,785 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

__ has exited due to signal 11 (SIGSEGV).

1 New Member
Hi!

i am writing a program in C that is a reservation maker. it supposed to ask if you wanna get first class or business class, and rest i have to finish. seats 1-5 are for first class, and seats 6-10 are for economy class. the probelm is that when seats 1-5 are full its supposed to ask if you wanna get a seat in economy and vice-versa. but everytime i get to seat 5 i get the error:
Airline has exited due to signal 11 (SIGSEGV).

can anyone help?? inew to C but not programming. THANKS

here is the functions class:


Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2.  
  3. void arrayInitializer (int array[], int sizeArray){
  4.         int i;
  5.         for(i = 0; i < sizeArray; i++){
  6.             array[i] = 0;
  7.            }
  8.   }
  9.  
  10. void menuChoose (int type, int seatArray[]){
  11.     int theClass;
  12.     int i;
  13.     if(type == 1){
  14.         for(i = 0; i < 5; i++){
  15.             theClass = 1;
  16.             if(seatArray[i] == 1) {
  17.                 if(i == 4 || (seatArray[0] == 1 && seatArray[1] == 1 && seatArray[2] == 1 && seatArray[3] == 1 && seatArray[4] == 1)) askOther(theClass, seatArray);
  18.                 else continue;
  19.                }
  20.             else if(seatArray[i] == 0){
  21.                 seatArray[i] = 1;
  22.                 printTicket(i, theClass);
  23.                 break;
  24.               }
  25.             }
  26.           }
  27.     else if(type == 2){
  28.         for(i = 5; i < 10; i++){
  29.             if(seatArray[i] == 1) continue;
  30.             else if(seatArray[i] == 0){
  31.                 seatArray[i] = 1;
  32.                 theClass = 2;
  33.                 printTicket(i, theClass);
  34.                 break;
  35.                }
  36.              else askOther(theClass, seatArray);
  37.              }
  38.            }
  39.     else printf("Hello!");
  40.   }
  41.  
  42. void printTicket(int seat, int theClass){
  43.     if(theClass == 1) printf("Boarding Pass: You Are In First Class And Your Seat Number is %d \n Enjoy your Flight!\n", seat);
  44.     else printf("Boarding Pass: You Are In Economy Class And Your Seat Number is %d \n Enjoy your Flight!\n", seat);
  45.   }
  46.  
  47. void askOther(int theClass, int seatArray[]){
  48.     char choice;
  49.     if(theClass == 1){
  50.         printf("First Class Is Full, Would You Like To Be Placed In Economy Class? (yes = y, no = n) ");
  51.         scanf("%c", choice);
  52.         if(choice == 'n') printf("Next Flight Leaves In Three Hours, Sorry");
  53.         if(choice == 'y') menuChoose( 2, seatArray);
  54.         else printf("Im Sorry, That Was Not A Valid Choice");
  55.         }
  56.     if(theClass == 2){
  57.         printf("Economy Class Is Full, Would You Like To Be Placed In First Class? (yes = y, no = n) ");
  58.         scanf("%c", choice);
  59.         if(choice == 'n') printf("Next Flight Leaves In Three Hours, Sorry");
  60.         if(choice == 'y') menuChoose( 1, seatArray);
  61.         else printf("Im Sorry, That Was Not A Valid Choice");
  62.         }
  63. }
  64.  
here is the driver class

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include "Driver.h"
  3.  
  4. int main(){
  5.  
  6. int decision, *decisionPtr;
  7. decisionPtr = &decision;
  8. int replay = 0;
  9. int seatArray[10] = { 0 };
  10.  
  11.  
  12. printf("Welcome To The Automated Reservation System\n");
  13. while(replay == 0){
  14. printf(" Please type ""1"" for First Class \n Please type ""2"" for Economy Class \n Please type ""3"" to cancel a reservation \n");
  15. scanf("%d", decisionPtr);
  16. menuChoose(*decisionPtr, seatArray);
  17. }
  18. return 0;
  19.  
  20. }
  21.  
thanks guys!
Sep 23 '07 #1
0 1722

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

Similar topics

3
3526
by: Martin McCormick | last post by:
A C program contains several signal statements to remove a lock file if the program gets killed: /*Set up interrupt handler to catch ctrl-C so that lock file can be removed.*/ signal(SIGINT,crash); signal(SIGBUS,crash); signal(SIGSEGV,crash); This part works. Those signals cause the "crash.c" module to run and get rid of the lock. Is there a standard way to also print
5
42614
by: Seo Jae Ick | last post by:
Hi? My name is Seo Jae Ick. I have a problem with running a program on Linux RedHat 8.0. GDB have reported this, program exited with code 0377 I think, this statement comes when 1) explicit call in process exit(-1) <- 0377(octet) = -1(decimal)
11
2975
by: Jackie | last post by:
Hi everyone, I'd like to know when and how signals are used (e.g. SIGFPE, SIGABRT, SIGTERM, SIGSEGV, SIGINT)? Thank you so much.
5
2613
by: Sontu | last post by:
Hi all, Consider the following code: #include<signal.h> #include<stdio.h> #include<sys/mman.h> void handler(int sig) {
13
17723
by: vashwath | last post by:
Hi all, In my current project I am using signals for error handling. Since I cannot show full code, I have just shown important piece of code which is relevant. void sigsegenv() { printf("\n\n ********** F D S Message ***********\n\n"); printf("\n\n ********** S E G M E N T A T I O N F A U L T inside F D S ***********\n\n");
5
1948
by: David Willoughby | last post by:
I'm attempting to catch bugs in my program using signal.h with sigsegv. now i know when i'm in gdb i can catch bugs but is there any variable that stores like the file that caused the bug and possible calling procs? or would that only be left to something with gdb.
10
4035
by: subramanian | last post by:
Consider the following code: segment violation is deliberately generated to catch the SIGSEGV signal. The handler for this signal, namely SIGSEGV_handler, is called. However after the handler is finished, control does not return to the printf statement in main() which is present after the strcpy statement. Instead Segmentation violation error message is printed in Redhat Linux and the program is aborted. In VC++, the SIGSEGV_handler is...
29
2108
by: Leet Jon | last post by:
Hi what's the reason for having the default disposition for SIGSEGV, SIGFPE, SIGBUS etc to be terminating the program, when these signals can just be ignored by the program? Many programs crash with SIGSEGV - they'd be much less flakey if the default was to try to carry on. ~Jon~
10
2149
by: Udai Kiran | last post by:
Hi all Iam having trouble with signal handler. Where will the execution return after invoking a signal handler when that particular signal is recieved? will return to the point where we register the signal? The following code is recieveing recursive signals. 2 #include <stdio.h> 3 #include <stdlib.h> 4 #include <unistd.h> 5
0
9646
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9484
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10350
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10097
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9957
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8983
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5386
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.