It jumps user input

When compiling the program, it works. But when it reaches to name input and movie name input, it jumps towards the next line.

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
  void add()
{
	FILE *outFile;
	outFile = fopen("movie.txt","w");
	
	struct Record cus[size];
	
	int a;
	char yn;
	
	for (a=0; a<size; a++)
	{
		printf("\nPlease enter Movie Booking Number ");
		scanf("%d", &cus[a].bNo);
		fprintf(outFile,"%d",cus[a].bNo);
		
		printf("\nPlease enter customer name \n");
		gets(cus[a].name);
		fprintf(outFile, "%s", cus[a].name);
		//it jumps the user input

		printf("\nPlease enter name of the movie\n");
		gets(cus[a].movie);
		fprintf(outFile, "%s", cus[a].movie);
		
		printf("Please enter the movie schedule (in turn of DD/MM/YYYY)\n");
		gets(cus[a].date);
		fputs(cus[a].date,outFile);
		
		printf("Please enter the time\n");
		scanf("%d", &cus[a].time);
		fprintf(outFile,"%d",cus[a].time);
		
		printf("Please enter the No. of ticket\n");
		scanf("%d", &cus[a].NoGuest);
		fprintf(outFile,"%d",cus[a].NoGuest);	
		
		printf("Please enter the No. house\n");
		scanf("%d", &cus[a].house);	
		fprintf(outFile,"%d",cus[a].house);
		
		printf("Please enter types of tickets\n");
		gets(cus[a].type);
		fflush(stdin);/*clear the buffer*/
		fputs(cus[a].name,outFile);
		
		printf("Please enter the total fee\n");
		scanf("%f", &cus[a].fee);
		fprintf(outFile,"%f",cus[a].fee);	
		
		printf("\n\nAdd another record(y/n) \n");
		scanf("%c", &yn);
		
		switch(yn)
		{
		case 'y':
			{
				continue;
			}
		case 'n':
			{
				fclose(outFile);
			}	
		}
	}
}
Last edited on
Topic archived. No new replies allowed.