首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

try块里的gets()函数,error:在此作用域未声明解决方案

2012-04-18 
try块里的gets()函数,error:在此作用域未声明C/C++ code#includeiostreamusing namespace stdint main(

try块里的gets()函数,error:在此作用域未声明

C/C++ code
#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;}

error:gets()在此作用域未声明,atof()在此作用域未声明

[解决办法]
貌似是没有包含头文件。
[解决办法]
#include <cstdio>
#include <cstdlib>

热点排行