ช่วยดู code ให้หน่อยคับ
ช่วยดูที คับว่า เขียนผิด รึป่าว ผมรันไม่ได้ ไม่รู้เป็นอะไร
#include<stdio.h> int num; char ans; int sum; int z; struct food{char name[20]; int age; }fd;
void insert_name(); void main()
{ clrscr(); void insert_name() { FILE *fp; char tmp[3]; if((fp=fopen(\"customer.txt\",\"a+t\"))==NULL) { printf(\"Cannot open file for insert data\\n\"); getch(); exit(1); }
printf(\"Name customer :\"); gets(fd.name); printf(\"Age :\"); gets(tmp); fd.age=atof(tmp); fwrite(&fd,sizeof(fd),1,fp); if(ferror(fp)) { printf(\"Error for insert name\\n\"); getch(); exit(1); fclose(fp); }
printf(\"What do you want to eat??\\n\"); printf(\"1.Hamburger\\n2.Hotdog\\n3.Fried chicken\\n4.Pizza\\n5.Sandwich\\n6.Exit\\n\"); printf(\"Please enter number:\"); scanf(\"%d\",&num); printf(\"How many :\"); scanf(\"%d\",&z); if(num==1) { printf(\"You want Hamburger is 50 Bath\"); sum = z*50; printf(\"\\nTotal is %d\",sum); } else if(num==2) { printf(\"You want Hotdog is 30 Bath\"); sum = z*30; printf(\"\\nTotal is %d\",sum); } else if(num==3) { printf(\"You want Fried chicken is 40 Bath\"); sum = z*40; printf(\"\\nTotal is %d\",sum); } else if(num==4) { printf(\"You want Pizza is 90 Bath\"); sum = z*90; printf(\"\\nTotal is %d\",sum); } else if(num==5) { printf(\"You want Sandwich is 30 Bath\"); sum = z*30; printf(\"\\nTotal is %d\",sum); } else { exit(); } getch(); } }
|