p3-141.cpp
来自「c++200源代码」· C++ 代码 · 共 25 行
CPP
25 行
#include<iostream.h>
#include<stdlib.h>
#define MAX 30
//main()的定义
int main(void)
{
char str[MAX];
//字符串转换为int和long类型数据
cout<<"Please input a string:"<<endl;
cin>>str;
int n=atoi(str);
cout<<"n="<<n<<endl;
long l=atol(str);
cout<<"l="<<l<<endl;
//字符串转换为double类型
cout<<"Please input a string:"<<endl;
cin>>str;
double x=atof(str);
cout<<"x="<<x<<endl;
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?