bai_jimmy

导航

C语言:void指针

使用前必须进行强制类型转换

#include <stdio.h>
void test(const void *p);
int main(){
        int i = 123;
        int *p = &i;
        puts("my test:");
        test(p);
}
void test(const void *p){
        const int *a = (const int *)p;
        printf("%d\n", *a);
}

 

posted on 2015-05-03 22:56  bai_jimmy  阅读(125)  评论(0)    收藏  举报