c语言 typedef的用法

来源:互联网 发布:如何在淘宝开充值店 编辑:程序博客网 时间:2024/06/11 06:16
#include <stdio.h>
#include <stdlib.h>


typedef int MyDefineInt;
typedef struct Node{
  int data;
  int * p;
}Node,*PNode;


void main()
{
 MyDefineInt intNumber = 1; //相当于 int intNumber  = 1;
 printf("intNumber = %d\n" , intNumber);


 Node node; //相当于 struct Node node;
 node.data = 10;
 node.p = (int *) malloc(sizeof(int)*10);
 printf("node.data = %d,node.p = %p\n",node.data , node.p);


 PNode pnode; //相当于 struct  Node *pnode
 pnode = (Node * ) malloc(sizeof(Node) * 10);
 int val = 5;
 pnode->data = val;
 pnode->p = (int *) malloc(sizeof(int)*10);
 printf("pnode->data = %d,pnode->p = %p\n",pnode->data , pnode->p);


}
0 0
原创粉丝点击