UOMOP

switch, break, goto 본문

Summary/C(++)

switch, break, goto

Happy PinGu 2022. 1. 31. 23:11
#include <stdio.h>
#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:4996)

int main() {

	int choice;

	makechoice:

	printf("1 : new game\n");
	printf("2 : load game\n");
	printf("3 : setting\n");
	printf("4 : credit\n\n");
	printf("what? : ");

	scanf("%d", &choice);

	switch (choice) {

	case 1:
		printf("new game!\n");
		break;

	case 2:
		printf("load game!\n");
		break;

	case 3:
		printf("setting!\n");
		break;

	case 4:
		printf("credit\n");
		break;

	default :
		printf("type again\n\n");
		goto makechoice;

	}

}

'Summary > C(++)' 카테고리의 다른 글

포인터, 이중 포인터  (0) 2022.01.31
strcpy, strcat, strcmp  (0) 2022.01.31
문자열 길이 찾기  (0) 2022.01.31
do, while  (0) 2022.01.31
C언어 자료형 정리  (0) 2022.01.27
Comments