About #define and typedef

来源:互联网 发布:对外汉语网络教师 编辑:程序博客网 时间:2024/06/05 20:56

I  wrote a simplified version function of vsprintf(char *buf, char *fmt, va_list args).

finally I found  I use "#define va_list char *"  rather than  "typedef char * va_list"

so , the following is the difference between them.

#define int_ptr int *
int_ptr a, b; // a is a pointer ,b is a int.

typedef int* int_ptr;
int_ptr a, b; //both a and b are pointer.

 

typedef int * pint ;
#define PINT int *

const pint p ;// p is unchanged ,the content that p point could be changed.
const PINT p ;//p could be changed ,the content that p point could not be changed.