Advertisement
inhuman_Arif

6b

Nov 8th, 2021
1,108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. #include <stdio.h>
  2. //structure
  3. struct student
  4. {
  5.    int age;
  6.    int id;
  7. };
  8.  
  9. int main()
  10. {
  11.  
  12.     struct student *personPtr, person1;//initializing pointer variable
  13.     personPtr = &person1; //The address of person1 is stored in pointer
  14.  
  15.     printf("Enter age: ");
  16.     scanf("%d", &personPtr->age); //accessing pointer variable using "->"
  17.  
  18.     printf("Enter ID: ");
  19.     scanf("%d", &personPtr->id);
  20.  
  21.    
  22.     printf("Age: %d\n", personPtr->age);
  23.     printf("Id: %d", personPtr->id);
  24.  
  25.     return 0;
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement