应用实例
int main()
{
char password[20] = { 0 };
printf("输入密码:>");
scanf("%s", password);
printf("请确认输入密码(Y/N):>");
//清理缓存区
int tmp = 0;
while ((tmp = getchar()) != '\n')
{
;
}
int ch = getchar();
if (ch == 'Y')
{
printf("确认成功\n");
}
else
{
printf("输出失败\n");
}
return 0;
}