第2个回答 2010-12-08
#include "stdafx.h"
#include<iomanip>
#include <iostream>
#include <cstdlib>
using namespace std;
int main( )
{
const int slength=20;
char s1[slength]="123";
char s2[slength]="123.4";
char *ps1,*ps2;
ps1=s1;ps2=s2;
cout<<atoi(ps1)<<endl; //转换成int类型
cout<<atof(ps2)<<endl; //转换成float类型
system("pause");
return 0;
}