1 #include <cstdlib> 2 #include <iostream> 3 #include <iterator> 4 #include "string.h" 5 using namespace std; 6 struct{ 7 short a1; 8 short a2; 9 short a3; 10 }A; 11 12 struct{ 13 long a1; 14 short a2; 15 }B; 16 17 int main() { 18 19 std::cout << "Hello World!\n"; 20 char *ss1 = "0123456789"; 21 char ss2[] = "0123456789"; 22 char ss3[100] = "0123456789"; 23 int ss4[100]; 24 25 char q1[] = "abc"; 26 char q2[] = "a\n"; 27 char *q3 = "a\n"; 28 29 char *str1 = (char *)malloc(100); 30 char *str2 = (char *)malloc(100); 31 32 cout << "sizeof(ss1) = " << sizeof(ss1) << endl; // 64位操作系统就是显示的8,32位操作系统显示的4. * 33 cout << "strlen(ss1) = " << strlen(ss1) << endl; //10 34 cout << "sizeof(ss2) = " << sizeof(ss2) << endl; //11* 35 cout << "sizeof(ss3) = " << sizeof(ss3) << endl; //100 36 cout << "sizeof(ss4) = " << sizeof(ss4) << endl; //400* 37 38 cout << "sizeof(q1) = " << sizeof(q1) << endl; //4 39 cout << "sizeof(q2) = " << sizeof(q2) << endl; //3 40 cout << "sizeof(q3) = " << sizeof(q3) << endl; //8* 41 42 cout << "sizeof(A) = " << sizeof(A) << endl; //6 43 cout << "sizeof(B) = " << sizeof(B) << endl; //16 * 44 45 cout << "sizeof(str1) = " << sizeof(str1) << endl; //8 * 46 cout << "sizeof(str2) = " << sizeof(str2) << endl; //8 * 47 48 49 50 return 0; 51 52 }
标签:std,short,struct,用法,a1,a2,include,Size From: https://www.cnblogs.com/xhu218/p/16886011.html