运行结果是:
#include #include using namespace std; int main() { int intA = atoi("919.5"); // int忽略不是0-9数字的字符,比如点 long lngA = atol("BaishiZhiDao.com666"); // 找不到就是0 string strA = to_string(789); // 数字转字符串 cout << intA << " " << lngA << " " << strA << endl; system("pause"); return 0; }
919 0 789