C examples for Structure:Structure Value
Use structure pointer operator ->
#include <stdio.h> #include <string.h> int main()/* ww w . ja v a 2 s. c om*/ { typedef struct player { char name[15]; float score; } p; p aPlayer = {0, 0}; // create instance of structure p *ptrPlayer; // create a pointer of structure type ptrPlayer = &aPlayer; // assign address to pointer of structure type strcpy(ptrPlayer->name, "Pinball Wizard"); // access through indirection ptrPlayer->score = 1000000.00; printf("\nPlayer: %s\n", ptrPlayer->name); printf("Score: %.0f\n", ptrPlayer->score); }