求教-->关于输入的问题atoi()
											我的代码及问题如下:
/*输入任意数字并转换为整形输出,要求非正确的输入一律重新输入,只到正确输入为止!*/
/*例如:-3.5转为-3、-5->-5、-0.3->0、0->0、0.56->0、8->8其它形式的都是错误输入*/
#include "stdlib.h"
#include "stdio.h"
main()
{
char x[20];
int b,i=0;
do
{
printf("Please input a integer:\n");
scanf("%s",&x);
if (x[i]=='e'||x[i]=='E') {printf("Exit!");break;}; /*按E键退出!*/
if(x[i]>='0'&& x[i]<'1'){printf("Intb=%d",atoi(x));break;}
/*这个是控制输入0<=x<1之间的数字时转为0*/
  /*问题:
    1、在此想控制输入-1到0之间的区域,此区域内的转换为0,不知道如何写?
    2、另外一个问题是:输入了如"3.88xr"这样的非法字符也被转换为3输出了
    3、如何控制输入的只为负数?请指教,谢谢*/
  b=atoi(x);
  if(b==0)
   {
    printf("Input error!");
    continue;
   }
  else
   {
   printf("Intb=%d",b);
   break;
   }
 }while(b!='\n') ;
 getch();
}

 
											





 
	    
 
											


