Bifalgorithm post · Computer science one · Alternative Declarations
What is the alternative way to declare a structure in C?
What is the alternative way to declare a structure in C? (Computer science one · Alternative Declarations) — "In some examples and code bases you may find an a…
Ideas in this flowchart
- Alternative declaration of a structure
- The syntax omits typedef and places the structure name at the beginning.
- The two declarations differ in how the structure name is placed in namespaces.
- Example of the alternative syntax: struct Student { ... };
- The original syntax creates an anonymous structure with Student in the global namespace.
- The alternative declaration places Student in the structure namespace.
- Student is therefore not available in the global scope as a type name.
- A variable must be declared by specifying the structure: struct Student s;