#include <iostream>
#include <string>
using namespace std;
int main()
{
char c1;//栈上4字节cccccccc
char c2[] = "Bravo";//8字节Brav o00cccc
char c4[] = "";//4字节00cccccc
string s1;//栈上16字节
string s2 = "Bravo";//cccccccc Bravo地址 长度 。。。。
string s3 = s2;
string s4(10, 'x');
cout << s1 << endl
<< s2 << endl
<< s3 << endl
<< s4 << endl;
cout << sizeof(s1);
return 0;
}
string与char的内存分配
最新推荐文章于 2024-04-27 09:43:02 发布