关于数组和指针的测试

来源:互联网 发布:雾林寒战知乎 编辑:程序博客网 时间:2024/06/05 09:11
    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;
    return0;
0 0