define和typedef的區別 define是單純的字元替換,typedef是重新定義了新的類型 ...
define和typedef的區別
define是單純的字元替換,typedef是重新定義了新的類型
#include <stdio.h>
#define CHAR1 char*
typedef char* CHAR2;
int main(){
char c = 'a';
CHAR1 pc1,pc2;//pc1是char指針,但pc2是char
pc1 = &c;
pc2 = c;
*pc1 = 'w';
printf("%c ", c);
CHAR2 pc3,pc4;//pc3,pc4都是char指針
pc3 = &c;
pc4 = &c;
*pc4 = 'e';
printf("%c ", c);
}