try块里的gets()函数,error:在此作用域未声明
#include<iostream>using namespace std;int main(){ char a[10]; double x; try { int flag=0; gets(a); for(int i=0;a[i]!='\0';i++) if(!(a[i]>='0'&&a[i]<='9'||a[i]=='.')){cout<<"输入为非数字"<<endl;flag=1;break;} if(flag==0) { throw 0; } } catch(int) { cout<<"输入为数字"<<endl; x=atof(a);//该函数把字符串(即数组中的全部元素)转换成数字 cout<<x<<endl; } return 0;}