C Programming 用scan 輸入String, 點先可以check 係唔係integer?

2008-11-12 2:36 am
char EnterInt[9];
scanf("%c", &EnterInt);

點可以check EnterInt 係唔係 >0 && <=999999999 ?

回答 (1)

2008-11-16 2:53 am
✔ 最佳答案
食左個 enterint 再 check 得唔得呀...

係咪唔0岩就要 output "input error"??
如果係就咁:
if(EnterInt<=0 || EnterInt>999999999){
cerr<<"input error\n";
exit(0);
}

2008-11-15 18:54:33 補充:
ah, sor, cerr 係 c++, 用番 printf 至0岩...


收錄日期: 2021-05-03 13:08:10
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20081111000051KK01242

檢視 Wayback Machine 備份