C25: Examples on Pointer Usage
Determine the output of the following program.
#include <stdio.h> #include <string.h> struct sample { char *name; int *id; float price; }; static char product[]="Red Plum Jam"; main() { int code = 312, number; char name[] = "Baked beans"; struct sample item; item.name = product; item.id = &code; item.price = 2.75; item.name = name; number = *item.id; printf("Name = %s\n", item.name ); printf("ID = %d\n", *item.id); printf("Price = %.2f\n", item.price ); } Name = Baked Beans ID = 312 Price = 2.75