1、关于指针的字节大小:
当为32位系统时大小为4字节,64位系统时大小为8字节;
#include<iostream> using namespace std; int main() { const char *str1 = "hello"; char str2[] = "hello"; cout << sizeof(str1) << " " << sizeof(str2) << endl; return 0; }
相反的话如果你的电脑运行出的4字节的话,就说你的系统是32位的;
2.关于数组元素的引用注意不要越界:
int a[5], *p = a; cout << *(p + 5);//越界;