fork(1) download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. typedef struct {
  5. char class[7];
  6. char age[6];
  7. char gender[7];
  8. }Passenger;
  9.  
  10.  
  11. /* This is where all the information about passengers will be stored, global variable,
  12. there are 9 combinations of passengers (allocated array elements for the variable), last one is reserved for the null character \0 */
  13. Passenger allPassengers[10];
  14.  
  15.  
  16. int main() {
  17.  
  18. // First combination
  19. strcpy(allPassengers[0].class, "first");
  20. strcpy(allPassengers[0].age, "adult");
  21. strcpy(allPassengers[0].gender, "male");
  22.  
  23.  
  24. // Second combination
  25. strcpy(allPassengers[1].class, "second");
  26. strcpy(allPassengers[1].age, "adult");
  27. strcpy(allPassengers[1].gender, "male");
  28.  
  29.  
  30. // Third combination
  31. strcpy(allPassengers[2].class, "first");
  32. strcpy(allPassengers[2].age, "child");
  33. strcpy(allPassengers[2].gender, "male");
  34.  
  35. // ... etc
  36.  
  37. return 0;
  38. }
Success #stdin #stdout 0s 2152KB
stdin
Standard input is empty
stdout
Standard output is empty