title: airline reservation system in c
body: <p>Im trying to create an airline reservation system, which shoulw reserve a ticket, display the reserved ticket, and do the cancelation of ticket.I have written the code, using array structures. For now the code is only executing the reserve ticket and exit. </p>
  
  <p>But when I press 1 for reserve ticket, it accepts the option but gives an error "Exception thrown at 0x0FFAFBB3 (ucrtbased.dll) in ConsoleApplication1.exe: 0xC0000005: Access violation writing location 0x0004B000." </p>
  
  <p>The code is stated below. Can anyone identify the error area in the code. </p>
  
  <pre><code>#include &lt;stdio.h&gt; 
  #include &lt;conio.h&gt; 
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  void initialize();
  void reserve(); 
  
  struct passengers {
  
  char* firstname;    
  char* surname;
  char* passport;
  };
  
  passengers passenger[10]; 
  
  
  void initialize()
  {
  for (int a = 0; a &lt; 10; a++) {
  
      passenger[a].passport = "";
      passenger[a].firstname = "";
      passenger[a].surname = "";
  
   }
  
   }
   void pause()
   {
  printf("\n");
  system("pause");
  system("cls");
  }
  
  
  int main()  {
  
  int seat = 0;
  
  initialize();
  
  int choice;
  
  do {
      system("cls");
      printf("\n\n\t\t*************************************\n\n");
      printf("\t  *****Welcome To airline reservation system*****\n\n"); 
      printf("\t\t\t   ******************");
      printf("\n\n\t\t  1. RESERVE SEAT");
      printf("\n\n\t\t  2. CANCEL SEAT");
      printf("\n\n\t\t  3. DISPLAY SEAT LAYOUT");
      printf("\n\n\t\t  4. EXIT SYSTEM");
      scanf_s("%d", &amp;choice); fflush(stdin);
  
  
      switch (choice) {
  
      case 1: reserve();
          break;
      case 2: cancel();
          break;
      case 3: display();
          break;
      case 4: exit(0);
          break;
      default:
          printf("\nInvalid Choice");
      }
  
   } while (choice != 4);
  
  
  
  _getch(); 
  
   }
  
  
   void reserve()   
  {
  int seat = 0;
  passenger[seat].firstname = (char*)malloc(15);
  passenger[seat].surname = (char*)malloc(15);
  passenger[seat].passport = (char*)malloc(9);
  
  for (int a = 0; a &lt; 10; a++)   
  {
  
      if (passenger[a].passport == "")
      {
          seat = a; 
          break;
      }
  
  
  }
  
  if (seat &lt; 10)
  {
      printf("\n\t\t Enter First Name:");
      scanf_s("%s", passenger[seat].firstname);
  
      printf("\n\t\t Enter Surname:");
      scanf_s("%s", passenger[seat].surname);
  
      printf("\n\t\t Enter Passport Number:");
      scanf_s("%s", passenger[seat].passport);
  
  
  }
  else {
  
      printf("\n\t\t Sorry, No seats are available");
  
  
  }
  
  pause();
  
  }
  </code></pre>