struct book
{
int id;
float price;
char name[15];
};
int main()
{
struct book b1 = {1,250.75,"ABC"};
display(&b1);
return 0;
}
void display(struct book* pbook)
{
printf("%d\t%f\t%s",pbook->id,pbook->price,pbook->name);
}
Address of b1 variable of book structure is passed to function display.It is collected in pointer to book structure.
You access members of structure through pointer using ->(arrow operator) or . (dot operator)
Remember that
pbook->id = (*pbook).id
No comments:
Post a Comment