Declaring structure variable
after defining a structure format we can declare vraiable of data type.
A structure variabel declaration is similar to the of variable of any other data
type.it includes the following elements
1.the keyword struct
2.the structure tag name
3.List of names separated of commas
For example ,the statement
struct book_bank,book1,book2,book3
declares book1,book2,book3 as variable of type struct book_bank
Declaration:
struct book_bank
{
char title[20];
char author[10;
int pages;
};
struct book_bank,book1,book2,book3;
remember that the member of a structure themselves are not variable .they
don't occupy any memory until they are associated with structure variable as book1
Type Defined structure:
we can use the keyword typedef to define a structure as follow
typedef struct
{
type member1;
type member2;
}type_name;
the type_name represent structure definition assoicated with it and therefore can beused to declare structure variable as shown
type_namevar1,var2;
0 comments:
Post a Comment