today.year = 2016;
And to test the value of month to see if it equals to 3, a statement is written as follows:
if( today.month = = 03 )
next_month = 01;
The
syntax of declaration of a structure
is
:
struct stname
{
datatype1 list_of_variables;
datatype1 list_of_variables;
…….
…….
datatype-n list_of_variables;
};
where
struct
is a keyword in C, followed by a
structure name, stname, or a tag
. The structure
ends with a closing brace and a semicolon. The data items in the structure are defined by a type,
followed by one or more identifiers, separated by commas.
For example,
struct Emp
{
char fname[40], lname[40];
int age;
float basic_salary;
char address[80];
};
Here, Emp is a new user-defined structure data type.
Please note that a structure declaration does not reserve any space for memory because a
structure declaration is just a data type, like an int, a float, or a char. Memory is allocated only
Do'stlaringiz bilan baham: |