Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- //structure
- struct student
- {
- int age;
- int id;
- };
- int main()
- {
- struct student *personPtr, person1;//initializing pointer variable
- personPtr = &person1; //The address of person1 is stored in pointer
- printf("Enter age: ");
- scanf("%d", &personPtr->age); //accessing pointer variable using "->"
- printf("Enter ID: ");
- scanf("%d", &personPtr->id);
- printf("Age: %d\n", personPtr->age);
- printf("Id: %d", personPtr->id);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement