下面程序运行后的结果为:
复制代码
char str[] = "glad to test something";
char *p = str;
p++;
int *p1 = reinterpret_cast<int *>(p);
p1++;
p = reinterpret_cast<char *>(p1);
printf("result is %s\n", p);
开始p指向“
glad to test something”中的g,然后p++,指向l
int *p1 = static_cast§; 把p赋值给int型了
p1++,即加了4个字节位置。
即p1指向“glad to test something”中的t
p = static_cast(p1); 把p1的转回了p,p指向了“
glad to test something”中的t
输出从t开始
to test something