Albert Leibnitz
Albert Leibnitz

Reputation: 43

What is the difference when defining structs with typedef?

Option 1:

typedef struct s{
                 int x;
                 double y;
                 char z;
                 }mystruct;

Option 2:

typedef struct {
                int x;
                double y;
                char z;
                }mystruct;

What's the difference between these 2 options?

Upvotes: 0

Views: 51

Answers (1)

Jabberwocky
Jabberwocky

Reputation: 50775

With option 1 you can declare a variable like this:

struct s foo;

or

mystruct foo;

With option 2 the only possibility is:

mystruct foo;

Upvotes: 1

Related Questions