scanf理解一

#include
void main()
{
double i;
while(1)
{

printf("請輸入員工的銷售額(元):");

printf("%lf",i);system("pause");


scanf("%lf",&i);                                        //若這裏輸入的是字符型,a,dsfr,等,將會使鍵盤緩衝區堵塞,scanf不回讀取任何數據而執行下面的代碼。
// fflush(stdin);                                            //將鍵盤緩衝區清空

printf("%lf",i);system("pause");

if(i>=0)
{
break;
system("pause");
}
else
{
printf("你輸入有誤請重新輸入");
}
}

}



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章