Structs can also be used with pointers to access and manipulate data dynamically.
#includestruct Person { char name[50]; int age; }; int main() { struct Person person1 = {"Alice", 30}; struct Person *ptr = &person1; printf("Name: %s\n", ptr->name); // Using pointer to access struct printf("Age: %d\n", ptr->age); return 0; }
This program demonstrates using a pointer ptr
to access and manipulate the members of a struct Person
.