17 lines
378 B
C
17 lines
378 B
C
|
#include <stdio.h>
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
char m = 'a'; // 97
|
||
|
short n = 127 + 129 + 97;
|
||
|
int x = 10;
|
||
|
void *p;
|
||
|
p = &m;
|
||
|
p = &n;
|
||
|
|
||
|
// (char *) 表示将 p 强制转换为 char 类型的指针,因为 void * 不能直接解引用, 他不能确定类型大小
|
||
|
printf("p->char, *p=%c\n", *(char *)p);
|
||
|
printf("p->short, *p=%d\n", *(char *)p);
|
||
|
|
||
|
return 0;
|
||
|
}
|