Concept

What is the alternative way to declare a structure in C?

ComputerScienceOne / Alternative Declarations

"In some examples and code bases you may find an alternative way of declaring a structure that looks like the following.\n\nstruct Student {\n\n...\n\n};\n\nThis syntax omits the keyword typedef and places the structure name at the beginning. The difference is a bit technical (the original syntax creates an anonymous structure with the Student identifier placed in the global namespace, while this declaration places the Student identifier in the structure namespace), but one of the consequences of using this type of declaration is that the Student identifier is not in the global scope, so to declare a variable of the type Student you need to further specify that it is a structure using the following syntax.\n\nstruct Student s;"

Related Ideas

What is the alternative way to declare a structure in C? | ComputerScienceOne | Bifalgorithm | Bifalgorithm