#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
void avengers(void)
{
printf("Avengers assemble!\n");
return 0;
}
void beep(void)
{
printf("\a\n");
return 0;
}
void count(void)
{
long input;
long num = 1;
char c;
while (scanf("%ld", &input) != 1)
{
printf("Your input - ");
while ((c = getchar()) != '\n')
putchar(c);
printf(" - is not a integer. Please try again. \n");
}
while (input + 1 > num)
{
printf("%ld\n", num);
num = num + 1;
}
return 0;
}
int main()
{
char c;
printf("Enter the letter of your choice: \n");
printf("a. avengers b. beep\n");
printf("c. count q. quit\n");
while (scanf("%c", &c) != 0)
{
if (c == 'a')
avengers();
else if (c == 'b')
beep();
else if (c == 'c')
count();
else if (c == 'q')
return 0;
else
printf("You need to choice in a to q");
while ((c = getchar()) != '\n')
continue;
printf("Enter the letter of your choice: \n");
printf("a. avengers b. beep\n");
printf("c. count q. quit\n");
}
return 0;
}
반응형
'C언어 > 따배씨 c언어' 카테고리의 다른 글
[따배씨] 팩토리얼 예제 (0) | 2022.12.15 |
---|---|
[따배씨] 변수의 영역과 지역변수 (0) | 2022.12.09 |
[따배씨] c = scanf("%d", &num); (0) | 2022.12.07 |
[따배씨] 8.4 인터페이스는 깔끔하게 - while (getchar() != '\n')의 의미 (0) | 2022.11.30 |
[c언어]continue와 break (0) | 2022.11.30 |