欢迎来到贱贱的博客

扩大
缩小

c语言typedef运用与函数指针

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 
 4 #define PINT int *
 5 typedef short* PSHORT;
 6 
 7 //typedef不是像宏一样简单的进行替换 这样定义的别名会作用与后出现的所有变量
 8 int main2()
 9 {
10     int a = 4;
11     short b = 5;
12     PINT pa1,pa2;
13     PSHORT pb1,pb2;
14     pa1 = &a;
15     //pa2 = pa1;// warning C4047: “=”:“int”与“int *”的间接级别不同 此处被pa2被解析为变量 不是指针
16     pb1 = &b;
17     pb2 = pb1;
18     //printf("*pa1=%d\t*pa2=%d",*pa1,*pa2);
19     printf("*pa1=%d\t*pa2=%d",*pb1,*pb2);
20     system("pause");
21 }

 

posted on 2016-11-07 15:18  L的存在  阅读(210)  评论(0编辑  收藏  举报

导航