Typedef, #define difference

typedef char *pStr1;
#define pStr2 char *;
pStr1 s1, s2;

pStr2 s3, s4

In the above variable definitions, s1, s2, and s3 are all defined as char *, and s4 is defined as char, which
is not the pointer variable we expected. The fundamental reason is that #define is just a simple string replacement,
and typedef It is a new name for a type.

Published 20 original articles · Likes6 · Visits 10,000+

Guess you like

Origin blog.csdn.net/weixin_36662608/article/details/54881808