Files
BankManager/utils.c
T

31 lines
588 B
C
Raw Normal View History

2026-04-06 21:36:26 +08:00
#include <stdio.h>
#include <stdlib.h>
#include "bank.h"
void ClearInput()
{
while(getchar() != '\n');
}
int GetInputInt(const char *prompt)
{
int value;
printf("%s", prompt);
while(scanf("%d", &value) != 1) {
ClearInput();
2026-04-22 17:32:22 +08:00
printf("输入错误,请重新输入: ");
2026-04-06 21:36:26 +08:00
}
return value;
}
double GetInputDouble(const char *prompt)
{
double value;
printf("%s", prompt);
while(scanf("%lf", &value) != 1) {
ClearInput();
2026-04-22 17:32:22 +08:00
printf("输入错误,请重新输入: ");
2026-04-06 21:36:26 +08:00
}
return value;
}