当前位置: 技术问答>linux和unix
谁能告诉我char*被强制转化成char**,内部是怎么运算的?
来源: 互联网 发布时间:2015-06-09
本文导语: char* p = "Hello"; printf("%cn", *(char**)p); // H is the output printf("%cn", *p); //H is the output printf("%dn", *(char**)p); //1948901838 is the output printf("%dn", *p); //72 is the output why this happen? | ch...
char* p = "Hello";
printf("%cn", *(char**)p); // H is the output
printf("%cn", *p); //H is the output
printf("%dn", *(char**)p); //1948901838 is the output
printf("%dn", *p); //72 is the output
why this happen?
printf("%cn", *(char**)p); // H is the output
printf("%cn", *p); //H is the output
printf("%dn", *(char**)p); //1948901838 is the output
printf("%dn", *p); //72 is the output
why this happen?
|
char* p="Hello";
当*(char**)p作为参数时,实际压栈的是'Hell',这是一个32位整型数,用十六进制表示是0x6C6C6548;
当*p作为参数时,实际压栈的是0x00000048,这是字符'H'扩展而来。
当*(char**)p作为参数时,实际压栈的是'Hell',这是一个32位整型数,用十六进制表示是0x6C6C6548;
当*p作为参数时,实际压栈的是0x00000048,这是字符'H'扩展而来。