Re: What is better and why?

Discussion in 'C Programming' started by Willem, Jun 10, 2013.

  1. Willem

    Willem Guest

    paskali wrote:
    ) 1st:
    )
    ) struct person {
    ) char *name;
    ) char *surname;
    ) };
    )
    ) 2nd:
    )
    ) typedef struct {
    ) char *name;
    ) char *surnname;
    ) } person;
    )
    ) 3th:
    )
    ) typedef struct person {
    ) char *name;
    ) char *surname;
    ) } person;
    )
    ) 4th:
    )
    ) typedef struct _PERSON {
    ) char *name;
    ) char *surnmae;
    ) } person;

    Don't forget the fifth form:

    typedef struct person person;

    struct person {
    char *name;
    char *surname;
    };


    SaSW, Willem
    --
    Disclaimer: I am in no way responsible for any of the statements
    made in the above text. For all I know I might be
    drugged or something..
    No I'm not paranoid. You all think I'm paranoid, don't you !
    #EOT
     
    Willem, Jun 10, 2013
    #1
    1. Advertising

  2. Willem

    James Harris Guest

    On Jun 10, 6:39 pm, Willem <> wrote:
    > paskali wrote:
    >
    > ) 1st:
    > )
    > ) struct person {
    > )     char *name;
    > )     char *surname;
    > ) };
    > )
    > ) 2nd:
    > )
    > ) typedef struct {
    > )     char *name;
    > )     char *surnname;
    > ) } person;
    > )
    > ) 3th:
    > )
    > ) typedef struct person {
    > )     char *name;
    > )     char *surname;
    > ) } person;
    > )
    > ) 4th:
    > )
    > ) typedef struct _PERSON {
    > )     char *name;
    > )     char *surnmae;
    > ) } person;


    (OT) I see you have indented manually. That may be your personal
    preference but if your newsreader sometimes has trouble with automatic
    indent for replies there is this which may help:

    http://codewiki.wikispaces.com/hkindent.ahk


    >
    > Don't forget the fifth form:
    >
    >   typedef struct person person;
    >
    >   struct person {
    >     char *name;
    >     char *surname;
    >   };


    How about:

    typedef struct person person_t;
    struct person {
    char *name;
    char *surname;
    };

    Would that be acceptable?

    James
     
    James Harris, Jun 11, 2013
    #2
    1. Advertising

  3. Willem

    Tim Rentsch Guest

    James Harris <> writes:

    > On Jun 10, 6:39 pm, Willem <> wrote:
    >
    >> Don't forget the fifth form:
    >>
    >> typedef struct person person;
    >>
    >> struct person {
    >> char *name;
    >> char *surname;
    >> };

    >
    > How about:
    >
    > typedef struct person person_t;
    > struct person {
    > char *name;
    > char *surname;
    > };
    >
    > Would that be acceptable?


    For some non-obvious technical reasons, a better pattern to
    follow to accomplish this is

    struct person;
    typedef struct person person_t;
    struct person {
    char *name;
    char *surname;
    };

    This is one of those things that almost never makes a difference,
    but when it does you'll be really glad the safer practice was
    followed.
     
    Tim Rentsch, Jun 15, 2013
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    977
    Mark Rae
    Dec 21, 2006
  2. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,218
    Smokey Grindel
    Dec 2, 2006
  3. Peter Bencsik
    Replies:
    2
    Views:
    878
  4. Andrew Thompson
    Replies:
    8
    Views:
    163
    Premshree Pillai
    Jun 7, 2005
  5. Replies:
    2
    Views:
    68
    Mark H Harris
    May 13, 2014
Loading...

Share This Page