Horje
typedef vs #define Code Example
typedef vs #define
**Difference**

1) typedef is limited to giving symbolic names to types only, whereas #define can be used to define an alias for values as well, e.g., you can define 1 as ONE, 3.14 as PI, etc.
2) typedef interpretation is performed by the compiler where #define statements are performed by preprocessor.
3) #define should not be terminated with a semicolon, but typedef should be terminated with semicolon.
4) #define will just copy-paste the definition values at the point of use, while typedef is the actual definition of a new type.
5) typedef follows the scope rule which means if a new type is defined in a scope (inside a function), then the new type name will only be visible till the scope is there. In case of #define, when preprocessor encounters #define, it replaces all the occurrences, after that (No scope rule is followed).




C

Related
delete string function in c Code Example delete string function in c Code Example
identifier bool is undefined in c Code Example identifier bool is undefined in c Code Example
fgets remove newline Code Example fgets remove newline Code Example
system(color ) Code Example system(color ) Code Example
c header file example Code Example c header file example Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8