数组和内存
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 char a[] = "Hello world!"; 2 char* r = a; 3 char* p = "Hello world!"; 4 char* q = (char*)malloc(sizeof(char) * sizeof(a)); 5 ::strcpy(q, a); 6 7 ASSERT_EQ(13, sizeof(a)); 8 ASSERT_EQ(4, sizeof(p)); 9 ASSERT_EQ(sizeof(p), sizeof(q)); 10 ASSERT_EQ(sizeof(q), sizeof(r)); 11 12 ASSERT_TRUE(strlen(a) == strlen(p)); 13 ASSERT_TRUE(strlen(q) == strlen(r)); 14 ASSERT_EQ(12, strlen(a)); 15 16 ASSERT_EQ(0, strcmp(r, a)); 17 ASSERT_EQ(0, strcmp(q, p)); 18 ASSERT_EQ(0, strcmp(q, a)); 19 ASSERT_EQ(0, strcmp(q, r)); 20 21 free(q); 22 q = 0;