Use structure pointer operator -> - C Structure

C examples for Structure:Structure Value

Description

Use structure pointer operator ->

Demo Code

#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); 
}

Related Tutorials