Can anybody explain the difference between
#define int* char
and
typedef int* char;
There's no difference because both are illegal.
int* isn't a valid identifier for a macro, and even if you put a space in, neither is int, because it's a keyword and reserved. Even if you switched it to your likely intended #define char int*, it fails for the same reason.
And you cannot redefine the type char, so the typedef is a bust.
The difference, had you given examples that were legal, is that #define is a preprocessing directive. It only does textual replacement, before the compiling stage. Contrarily typedef defines a new type, and that new type identifier respects "the rules" just like any other type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With