Thread: difference between these two stucts

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    70

    difference between these two stucts

    Hi
    can some one tell me if there is difference between these two bits of code

    Code:
    typedef struct
    {int a[10];
    float b[12];
    char c}mystruct;
    
    mystruct structinstance;
    &
    Code:
    struct mystruct
    {int a[10];
    float b[12];
    char c;
    }
    struct mystruct structinstance;
    if both are valid, which one is better to use?

  2. #2
    /*enjoy*/
    Join Date
    Apr 2004
    Posts
    159
    the differnce between the two is :

    the 1st is a predifine type

    (mystruct) equivalents has ( int)

    in this case you can declare variables of type (mystruct)

    in the second case you you are limited has an alone structures

    and I do not know if you can use it so much faiths as the first
    Code:
    then I counsel you to use the first
    Code:
    exuse me for mistakes because i use a translator

  3. #3
    Registered User
    Join Date
    May 2004
    Posts
    127
    Quote Originally Posted by studentc
    Hi
    can some one tell me if there is difference between these two bits of code

    Code:
    typedef struct
    {int a[10];
    float b[12];
    char c}mystruct;
    
    mystruct structinstance;
    &
    Code:
    struct mystruct
    {int a[10];
    float b[12];
    char c;
    }
    struct mystruct structinstance;
    if both are valid, which one is better to use?
    The difference is that with the second example you have no choice but to use the struct keyword. With the first example you have no choice but to omit it. Functionally they're both the same though. Which you use is a matter of personal preference.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Finding the difference in two times
    By muthus in forum C++ Programming
    Replies: 4
    Last Post: 01-24-2008, 06:36 PM
  2. Difference Equations / Recurrence Relations
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 10-05-2007, 10:26 AM
  3. What's the difference between var++ and ++var
    By ulillillia in forum C Programming
    Replies: 6
    Last Post: 05-31-2007, 02:27 AM
  4. Replies: 6
    Last Post: 08-26-2006, 11:09 PM
  5. Difference between macro and pass by reference?
    By converge in forum C++ Programming
    Replies: 2
    Last Post: 02-26-2002, 05:20 AM