Macros Vs typedef

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sridhard2406
    New Member
    • Dec 2007
    • 52

    Macros Vs typedef

    Hi All,
    What is basic difference using macors and typedef in C program

    Thanks
    Sridhar.D
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    A typedef just renames an already existing type. If all your macro does is provide an alias for a type, then the macro and the typedef are identical functionally.

    Code:
    typedef  int NUMBER;
    
    #define NUMBER  int
    However, a macro can be used to represent blocks of code which a typedef cannot.

    Comment

    • sridhard2406
      New Member
      • Dec 2007
      • 52

      #3
      Thanks for your reply

      Comment

      Working...