这个程序,我在LCC-win32中运行OK,思路是用getchar()函数先判断小数点,然后判断紧跟在小数点后的是数据还是空格。
include <stdio.h>
#include <ctype.h>
int main(void)
{
int i;
while(((scanf("%d",&i))) !=EOF)
{
if(!isspace(getchar())) //judge the input data is or not float
{
printf("please input the data with integer type\n");
while(!isspace(getchar())) //throw off the data that followed the decimal
continue;
continue;
}
printf("the input is ok:%d\n",(int)i);
}
return 0;