C coding

i have a problem with my C coding...everytime i run the program...it will skip certain line and i can't enter my input for that line...here is my coding look like..

/*Name :
Matric num :
Lab Group : 1b
Purpose : Hand on test*/

#include <stdio.h> //header
#include <stdlib.h>

int main()
{ //applicant information
char name[30];
char faculty[30];
char matric_no[20];
char date[10];
char vehicle[20];
char destination[50];
char travelling_purpose[50];

int time1, time2, number_passengers;
int mobile_no, total_hours;

printf("Please enter your name : ");
gets(name);
printf("\nPlease enter your faculty name : ");
gets(faculty);
printf("\nPlease enter your matric number : ");
scanf("%s", &matric_no);
printf("\nDate : ");
scanf("%s", &date);
printf("\nPlease enter your mobile number : ");
scanf("%d", &mobile_no);

//booking information




printf("\nType of vehicle : ");
scanf("%s", &vehicle);

printf("\nBooking Date : ");
scanf("%s", &date);

printf("\nBooking time (24hours) from : ");
scanf("%d",&time1);

printf(" \t\t\tto : ");
scanf("%d",&time2);

printf("\nDestination : ");
gets(destination);

printf("\nTravelling Purpose : ");
gets(travelling_purpose);

printf("\nNumber of passengers : ");
scanf("%d",&number_passengers);

total_hours= time2-time1 ;

//printf("Total hours : %d", total_hours);


printf("\t\t\tSTUDENT VEHICLE BOOKING FORM\n");
printf("================================================================================");
printf("\nAPPLICANT INFORMATION");
printf("\n================================================================================");
printf("\nName : %s", name);
printf("\t\t\t\tMatric Number : %s\n", matric_no);
printf("\nFaculty : %s", faculty);
printf("\t\t\t\tMobile Number : %d\n", mobile_no);
printf("\nDate : %s\n\n", date);

printf("================================================================================");
printf("\nBOOKING INFORMATION");
printf("\n================================================================================");
printf("\n\nType of vehicle : %s", vehicle);
printf("\n\nBooking Date : %s", date);
printf("\n\nBooking Time from>>> %d hour", time1);
printf(" to>>> %d hour", time2);
printf("\n\nTotal booking time : %d hour", total_hours);
printf("\n\nDestination : %s", destination);
printf("\n\nTravelling Purpose : %s", travelling_purpose);
printf("\n\nNumber of passengers : %d", number_passengers);


return 0;
}

if i run this coding...it will not read the destination part...can anyone give a hand?..thank you..
How about instead of gets()
Scanf("%s",&destination);
These problems usually involve satisfactorily flushing the keyboard buffer. I'll work on it a bit and see if I can fix it. Bobdabilder's suggestion is worth a try too.
I got this to work ...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <stdio.h> //header
#include <stdlib.h>

int main()
{ //applicant information
  char name[30];
  char faculty[30];
  char matric_no[20];
  char date[10];
  char vehicle[20];
  char destination[50];
  char travelling_purpose[50];

  int time1, time2, number_passengers;
  int mobile_no, total_hours;

  printf("Please enter your name : ");
  gets(name);
  printf("\nPlease enter your faculty name : ");
  gets(faculty);
  printf("\nPlease enter your matric number : ");
  scanf("%s", (char*)&matric_no);
  printf("\nDate : ");
  scanf("%s", (char*)&date);
  printf("\nPlease enter your mobile number : ");
  scanf("%d", &mobile_no);

  //booking information

  //getchar();
  fflush(stdin);
  printf("\nType of vehicle : ");
  scanf("%s", (char*)&vehicle);
  printf("\nBooking Date : ");
  scanf("%s", (char*)&date);


  printf("\nBooking time (24hours) from : ");
  fflush(stdin);
  scanf("%d",&time1);

  printf(" \t\t\tto : ");
  fflush(stdin);
  scanf("%d",&time2);

  //getchar();

  printf("\nDestination : ");
  fflush(stdin);
  gets(destination);

  printf("\nTravelling Purpose : ");
  gets(travelling_purpose);

  printf("\nNumber of passengers : ");
  scanf("%d",&number_passengers);

  total_hours= time2-time1 ;

  //printf("Total hours : %d", total_hours);


  printf("\t\t\tSTUDENT VEHICLE BOOKING FORM\n");
  printf("================================================================================");
  printf("\nAPPLICANT INFORMATION");
  printf("\n================================================================================");
  printf("\nName : %s", name);
  printf("\t\t\t\tMatric Number : %s\n", matric_no);
  printf("\nFaculty : %s", faculty);
  printf("\t\t\t\tMobile Number : %d\n", mobile_no);
  printf("\nDate : %s\n\n", date);

  printf("================================================================================");
  printf("\nBOOKING INFORMATION");
  printf("\n================================================================================");
  printf("\n\nType of vehicle : %s", vehicle);
  printf("\n\nBooking Date : %s", date);
  printf("\n\nBooking Time from>>> %d hour", time1);
  printf(" to>>> %d hour", time2);
  printf("\n\nTotal booking time : %d hour", total_hours);
  printf("\n\nDestination : %s", destination);
  printf("\n\nTravelling Purpose : %s", travelling_purpose);
  printf("\n\nNumber of passengers : %d", number_passengers);

  return 0;
}


Do a search on ...

"How To Flush The Keyboard Typeahead Buffer."
awesome!!!..thanks guys...
You also may want to look at fgets().
fgets(name,30-1,stdin);
for example.
Topic archived. No new replies allowed.