![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Why, you might ask, do structure definitions end with a semicolon? After all, the final brace makes it clear where the structure definition ends:
*---- Semicolon | v struct trade {double price; int number;};
One reason is that the semicolon syntax allows you to describe a structure
and to define global variables using that structure in a single statement.
In the following single statement, for example, the trade
structure
is defined and global variables t1
and t2
are defined to
belong to the trade
structure.
struct trade {double price; int number;} t1, t2;
Thus, the semicolon tells C where the list of defined variables ends.