char *p1 = "hello";
char *p2 = "world";
char *p3 = "a piece of cake";
char *str[] = { p1, p2, p3 };
cout << sizeof(*str[0]) << " " << typeid(str[0]).name() << " " << *(str[0] + 1) << endl;//typeid是类型
cout << sizeof(*&str[0]) << " " << typeid(&str[0]).name() << " " << *(&str[0] + 1) << endl;
cout << sizeof(*str) << " " << typeid(str).name() << " " << *(str + 1) << endl;
cout << sizeof(*&str) << " " << typeid(&str).name() << " " << *(&str + 1) << endl;
return 0;
数组和指针相关
最新推荐文章于 2024-05-02 11:05:21 发布