Search
 
SCRIPT & CODE EXAMPLE
 

C

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).
Comment

PREVIOUS NEXT
Code Example
C :: c strstr 
C :: C (ANSI) 
C :: c sizeof operator 
C :: c typedef 
C :: c check if character is a space 
C :: adjacency matrix representation maker 
C :: c exit 
C :: read file c 
C :: how to input n space separated integers in c 
C :: how to empty array in c 
C :: c print 
C :: FCFS algorithm in c to find average turnaround time and waiting time 
C :: Initialization of a 3d array in c 
C :: argparse allow line break 
C :: arduino empty serial buffer 
C :: c defined 
C :: snprintf c 
C :: round c 
C :: size of int in c 
C :: linear and binary search 
C :: lxde automatic login 
C :: c to assembly converter 
C :: Multiplying a u64 to u128 in Rust 
C :: install lib juicyPixel in haskell 
C :: Uri/Beecrowd problem no - 1151 solution in C 
C :: how to limit tiktok on mikrotik 
C :: c pointers to struct 
C :: reverse binary tree c 
C :: C linked sorted lists 
C :: wpdb add temporary while drop table 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =