C++的atof()

atof 是ascII to float的缩写,它将ascII字符串转换为相应的单精度浮点数,比如传入"1.234",经过处理后就返回float类型的数1.234 。类似的还有atoi 、atol、itoa、ftoa等等。

示例程序,主函数使用两个值作为实参,并输出和。

#include 
using namespace std;
int main(int argc,char *argv[])
{
	if(argc!=3){
		cout<<"you should use three arguments"<


将程序编译成sum.exe, 在命令行下运行 sum 1.23 2.56, 返回3.79.


你可能感兴趣的:(程序设计)