I want to know the actual use of struct tag_name in C programming. Without using the tag_name also i was getting output as with use of tag_name. I want the exact reason behind t
In the first case :
struct st1 {
int x;
char c;
} x = {100, 'a'}, y = {70, 'e'};
you declare a type with name struct st1
, and you also create two objects, of this type, x
and y
. So you can create objects of this type whenever you want, like this :
struct st1 obj1;
However in the second case :
struct {
int x;
char c;
} x = {100, 'a'}, y = {70, 'e'};
you create a struct
and two objects, x
and y
, but you cannot access this struct
again. This means that you cannot create any new objects of this type.