#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    30
    Rep Power
    1

    Typedef question


    What does this code mean?
    typedef struct myStruct *newStruct;

    I know that struct myStruct is also known as *newStruct, but could you please explain the *newStruct? What is it...Is it a pointer?

    Thanks.
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Location
    Saint-Petersburg, Russia
    Posts
    236
    Rep Power
    28
    I know that struct myStruct is also known as *newStruct
    You are bit wrong. You should say:

    struct myStruct*
    is known as
    newStruct

    i.e. newStruct is a type "pointer to struct myStruct"
  4. #3
  5. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,075
    Rep Power
    1802
    Although the language syntax does not require it, it is clearer to place the * qualifier with the with the base type that it qualifies rather than the type name that is being defined.

    Code:
    typedef struct myStruct* newStruct ;
    Last edited by clifford; October 9th, 2013 at 03:58 AM.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    30
    Rep Power
    1
    Thanks to the both of you man, now that I know it... :)

IMN logo majestic logo threadwatch logo seochat tools logo