Author Topic: typedef  (Read 1043 times)

thrushitha

  • Full Member
  • ***
  • Posts: 26
typedef
« on: July 07, 2011, 04:44:23 am »
wat does typedef signify?
when we need to use typedef?



thanks in advance

kathir

  • Administrator
  • Sr. Member
  • *****
  • Posts: 283
Re: typedef
« Reply #1 on: July 07, 2011, 12:00:36 pm »
wat does typedef signify?
when we need to use typedef?
thanks in advance

typedef is used for couple of purpose.

1. If the user defined struct length is too much, then we go with typedef.
2. Cross platform - bool data type is not supported in Turbo C. But it supported in Visual C++. If you want to simulate vc++ bool data type in Turbo C, you can use the code given below:

typedef enum _boolean
{
    true = 1, false = 0
} bool;

3. Conventional purpose - You can have your own coding convention for data types like U32, S32, DWORD, etc. U32 is nothing but unsigned int of 32 bits. It can be defined like given below,

typdef unsigned int U32;
typdef signed int S32;
typdef unsigned long DWORD;
typdef char BYTE;
typdef _int16 S16;



 


Disclaimer: This web site is for educational and informational purposes only. Click here to read the Disclaimer.
Content copyright 2010-2014. Kathiresan. All rights reserved.
This page is using SMF version 2.0.1