Skip to content

Instantly share code, notes, and snippets.

@surinoel
Created July 4, 2019 11:38
Show Gist options
  • Save surinoel/426951b4cef5bdaf07789f5a33f772c8 to your computer and use it in GitHub Desktop.
Save surinoel/426951b4cef5bdaf07789f5a33f772c8 to your computer and use it in GitHub Desktop.
static void cancle_movie_ticket(void)
{
long long curtimetick, flagtick;
system("cls");
char buf[20], moviebuf[20]; memset(buf, 0, sizeof(buf)); memset(moviebuf, 0, sizeof(buf));
bool ok = false;
printf("\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t "); printf("회원 이름을 입력해주세요: "); scanf("%s", buf);
for (int i = 0; i < _msize(user) / sizeof(*user); i++) {
ok = true;
if (!strcmp(buf, user[i].name)) { // 회원 정보와 맞다면
int pswd;
printf("\t\t %s님! 비밀번호를 입력하세요: ", user[i].name); scanf("%d", &pswd);
if (pswd == user[i].password) {
if (user[i].mt->seatcnt != 0) show_userinfo(user[i]);
else goto err; // 좌석 정보가 있다면
}
else {
goto err2;
}
system("cls");
printf("\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t "); printf("취소할 영화이름을 입력해주세요: "); scanf("%s", moviebuf);
if (!strcmp(moviebuf, user[i].mt->movieTitle)) {
user[i].money += user[i].mt->ticketprice * user[i].mt->seatcnt; // 돈을 환불하고
free(user[i].mt); // 사용자의 영화 정보를 삭제
user[i].mt = (struct MovieTicket *)malloc(sizeof(struct MovieTicket)); // 새롭게 할당
memset(user[i].mt, 0, sizeof(user[i].mt));
user[i].mt->seatcnt = 0; // 사용자 자리 정보 초기화
}
else {
goto err2;
}
}
}
if (!ok) goto err2;
return;
err:
error_handler(5, "예매내역이 없습니다", "프로그램이 종료됩니다");
return;
err2:
error_handler(5, "사용자 입력을 다시 확인해주세요", "메뉴로 넘어갑니다");
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment