//getchar
#include<stdio.h>
int main()
{
//
char password[20] = { 0 };
printf("请输入密码:>");
scanf_s("%s", password);
printf("请确认密码(Y/N):>" );
//清理缓冲区
//getchar();//处理'\n'
//清理缓冲区的多个字符
int tmp = 0;
while (tmp = getchar()!='\n')
{
;
}
int ch = getchar();
if (ch == 'Y')
{
printf("确认成功\n");
}
else
{
printf("确认失败\n");
}
return 0;
}
标签:tmp,ch,int,printf,password,getchar
From: https://www.cnblogs.com/xiaofu2022/p/16897660.html