Hello!
Can somebody tell me is name tag for structures required? I tried to find the answer in my C book but i found nothing.
Thanks.
Hello!
Can somebody tell me is name tag for structures required? I tried to find the answer in my C book but i found nothing.
Thanks.
That depends. If you want to create instances of it later, yes. Otherwise no.
The above is fine. However, you're unable to create other instances, because you have no way of referencing it:Code:struct { int x; } instance; instance.x = 10;
Quzah.Code:struct __oops no name___ instance2; /* you have no name, so you can't */
Hope is the first step on the road to disappointment.
Technically, this is also an unnamed struct except its reffered to as Point:
What's really neat about the above is that you don't have to specify its a struct when you want to declare one. Note no struct keyword in the following:Code:typedef struct { int x, y, z; } Point;
Code:Point p;