-
Notifications
You must be signed in to change notification settings - Fork 0
/
revision.c
97 lines (77 loc) · 3.39 KB
/
revision.c
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
88
89
90
91
92
93
94
95
96
97
/*revision.c 修正処理*/
#include"hotel.h"
revision(){
int i=0,menu,roomno;
FILE *file;
printf("\n===修正処理===\n\n");
file=fopen("reservation.txt","r");
fseek(file,0,SEEK_SET);
while(fscanf(file,"%d %s %s %s %d %s %d\n",&customer[i].p_reservation_r,customer[i].p_name_r,customer[i].p_tel_r,customer[i].p_address_r,&customer[i].p_charge_r,customer[i].p_roomTyp_r,&customer[i].p_roomNo_r)!=EOF){
i++;
}
END2=i;
printf("予約をしている顧客の部屋番号を入力してください入力してください:\n");
scanf("%d",&roomno);
for(i=0;i<END2;i++){
if(roomno==customer[i].p_roomNo_r){
customer[i].p_reservation_r=customer[i+1].p_reservation_r;
strcpy(customer[i].p_name_r,customer[i+1].p_name_r);
strcpy(customer[i].p_tel_r,customer[i+1].p_tel_r);
strcpy(customer[i].p_address_r,customer[i+1].p_address_r);
customer[i].p_charge_r=customer[i+1].p_charge_r;
strcpy(customer[i].p_roomTyp_r,customer[i+1].p_roomTyp_r);
customer[i].p_roomNo_r=customer[i+1].p_roomNo_r;
customer[i+1].p_reservation_r=customer[i+2].p_reservation_r;
strcpy(customer[i+1].p_name_r,customer[i+2].p_name_r);
strcpy(customer[i+1].p_tel_r,customer[i+2].p_tel_r);
strcpy(customer[i+1].p_address_r,customer[i+2].p_address_r);
customer[i+1].p_charge_r=customer[i+2].p_charge_r;
strcpy(customer[i+1].p_roomTyp_r,customer[i+2].p_roomTyp_r);
customer[i+1].p_roomNo_r=customer[i+2].p_roomNo_r;
}
}
fseek(file,0,SEEK_END);
fclose(file);
file=fopen("reservation.txt","w");
fseek(file,0,SEEK_SET);
for(i=0;i<END2-1;i++){
fprintf(file,"%d ",customer[i].p_reservation_r);
fprintf(file,"%s ",customer[i].p_name_r);
fprintf(file,"%s ",customer[i].p_tel_r);
fprintf(file,"%s ",customer[i].p_address_r);
fprintf(file,"%d ",customer[i].p_charge_r);
fprintf(file,"%s ",customer[i].p_roomTyp_r);
fprintf(file,"%d\n",customer[i].p_roomNo_r);
}
fseek(file,0,SEEK_END);
fclose(file);
file=fopen("reservation.txt","a");
for(i=0;i<MAX;i++){
printf("\n修正処理を行います、\n1を入力し以下の項目を入力してください:");
scanf("%d",&menu);
if(menu==0)
break;
printf("\n予約する日付を入力してください:");
scanf("%d",&customer[i].p_reservation_r);
fprintf(file,"%d ",customer[i].p_reservation_r);
printf("名前を入力してください:");
scanf("%s",customer[i].p_name_r);
fprintf(file,"%s ",customer[i].p_name_r);
printf("電話番号を入力してください:");
scanf("%s",customer[i].p_tel_r);
fprintf(file,"%s ",customer[i].p_tel_r);
printf("顧客の住所を入力してください:");
scanf("%s",customer[i].p_address_r);
fprintf(file,"%s ",customer[i].p_address_r);
printf("料金を入力してください:");
scanf("%d",&customer[i].p_charge_r);
fprintf(file,"%d ",customer[i].p_charge_r);
printf("部屋のタイプを入力してください:");
scanf("%s",customer[i].p_roomTyp);
fprintf(file,"%s ",customer[i].p_roomTyp);
printf("部屋番号を入力してください:");
scanf("%d",&customer[i].p_roomNo_r);
fprintf(file,"%d\n",customer[i].p_roomNo_r);
}
fclose(file);
}