C++ 标准学习--基础类型的初始化方式
#include <iostream>
#include <sstream>
#include<cstring>
int main()
{
int val = int();
char ch = char();
string str = string();
cout << val << endl;
cout << "char is: " << ch << endl;
cout << (int)ch << endl;
cout << "string is: " << str << endl;
cout << "string size: " << strlen(str.c_str()) << endl;
stringstream itost;
itost << str;
int x;
itost >> x;
cout << "to i: "<< x << endl;
cout << stoi(str.c_str()) << endl;
return 0;
}
输出结果为:
原文地址:https://blog.csdn.net/baidu_16271159/article/details/135498317
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!