avroopa / hi

0 stars 0 forks source link

Failed to compile #1

Open RishabhRawat opened 8 years ago

RishabhRawat commented 8 years ago

Fails to compile, and check the warnings, I can see atleast 4-5 mistakes in warnings only, more in errors

ap.c: In function ‘menu’:
ap.c:17:11: warning: implicit declaration of function ‘view’ [-Wimplicit-function-declaration]
 { case 1: view();
           ^
ap.c:18:4: warning: implicit declaration of function ‘getch’ [-Wimplicit-function-declaration]
    getch();
    ^
ap.c:21:11: warning: implicit declaration of function ‘reserve’ [-Wimplicit-function-declaration]
   case 2: reserve();
           ^
ap.c:25:11: warning: implicit declaration of function ‘cancel’ [-Wimplicit-function-declaration]
   case 3: cancel();
           ^
ap.c: At top level:
ap.c:31:6: warning: conflicting types for ‘view’
 void view()
      ^
ap.c:17:11: note: previous implicit declaration of ‘view’ was here
 { case 1: view();
           ^
ap.c:43:6: warning: conflicting types for ‘reserve’
 void reserve()
      ^
ap.c:21:11: note: previous implicit declaration of ‘reserve’ was here
   case 2: reserve();
           ^
ap.c: In function ‘reserve’:
ap.c:62:9: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int *’ [-Wformat=]
  printf("Your fare is Rs.%d",&a);
         ^
ap.c:69:9: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int *’ [-Wformat=]
  printf("Your fare is Rs.%d",&a);
         ^
ap.c:75:9: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int *’ [-Wformat=]
  printf("Your fare is Rs.%d",&a);
         ^
ap.c:83:8: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[20]’ [-Wformat=]
  scanf("%s",&s.name);
        ^
ap.c:87:8: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[50]’ [-Wformat=]
  scanf("%s",&s.address);
        ^
ap.c:95:9: warning: format ‘%c’ expects argument of type ‘int’, but argument 2 has type ‘char (*)[20]’ [-Wformat=]
  printf(" Name: %c                                                                                     \n",&s.name);
         ^
ap.c:96:9: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int *’ [-Wformat=]
  printf(" Phone Number: %d                                                                             \n",&s.phno);
         ^
ap.c:97:9: warning: format ‘%c’ expects argument of type ‘int’, but argument 2 has type ‘char (*)[50]’ [-Wformat=]
  printf(" Address: %c                                                                                  \n",&s.address);                   
         ^
ap.c:98:9: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int *’ [-Wformat=]
  printf(" Tickets Booked: %d                                                                           \n",&s.ticketno);
         ^
ap.c: At top level:
ap.c:108:6: warning: conflicting types for ‘cancel’
 void cancel()
      ^
ap.c:25:11: note: previous implicit declaration of ‘cancel’ was here
   case 3: cancel();
           ^
/tmp/cc7X7y1D.o: In function `menu':
ap.c:(.text+0x8b): undefined reference to `getch'
ap.c:(.text+0xab): undefined reference to `getch'
ap.c:(.text+0xcb): undefined reference to `getch'
/tmp/cc7X7y1D.o: In function `view':
ap.c:(.text+0x165): undefined reference to `getch'
/tmp/cc7X7y1D.o: In function `reserve':
ap.c:(.text+0x3a6): undefined reference to `getch'
/tmp/cc7X7y1D.o:ap.c:(.text+0x4b3): more undefined references to `getch' follow
collect2: error: ld returned 1 exit status
RishabhRawat commented 8 years ago

A sample output of the code

1.VIEW ALL TRAINS

2.RESERVE A TICKET

3.CANCEL A TICKET
Enter your choice(1,2 or 3)2
Enter the train code1021

 1.first class(fare Rs1500 )
 2.second class(fare Rs1000)
 3.sleeper class(fare Rs500)1
Enter number of tickets to be booked5
Your fare is Rs.2024084156
Enter the nameRisah

Enter the phone number9167520442

 Enter the addressU-erec sd#
Number of ticketsYour ticket is confirmed
Here is your ticket
-----------------------------------------------------------------------------------------------
                             APOORVA'S RAILWAY NETWORK                                        
 Name: �                                                                                     
 Phone Number: 6299796                                                                             
 Address: �                                                                                  
 Tickets Booked: 6299852                                                                           
                               HAVE A NICE JOURNEY!                                          
-----------------------------------------------------------------------------------------------
RishabhRawat commented 8 years ago

@avroopa The warning messages

railway.c: In function ‘reserve’:
railway.c:65:9: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int *’ [-Wformat=]
  printf("Your fare is Rs.%d",&a);
         ^
railway.c:72:9: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int *’ [-Wformat=]
  printf("Your fare is Rs.%d",&a);
         ^
railway.c:78:9: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int *’ [-Wformat=]
  printf("Your fare is Rs.%d",&a);
         ^
railway.c:86:8: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[20]’ [-Wformat=]
  scanf("%s",&s.name);
        ^
railway.c:90:8: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[50]’ [-Wformat=]
  scanf("%s",&s.address);
        ^
railway.c:98:9: warning: format ‘%c’ expects argument of type ‘int’, but argument 2 has type ‘char (*)[20]’ [-Wformat=]
  printf(" Name: %c                                                                                     \n",&s.name);
         ^
railway.c:99:9: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int *’ [-Wformat=]
  printf(" Phone Number: %d                                                                             \n",&s.phno);
         ^
railway.c:100:9: warning: format ‘%c’ expects argument of type ‘int’, but argument 2 has type ‘char (*)[50]’ [-Wformat=]
  printf(" Address: %c                                                                                  \n",&s.address);                   
         ^
railway.c:101:9: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int *’ [-Wformat=]
  printf(" Tickets Booked: %d                                                                           \n",&s.ticketno);
         ^
avroopa commented 2 years ago

test comment