The reason for this is that a pointer to an int is a simple data type, while a struct is a more complex data type. When we dereference a pointer to an int, we get a reference to the underlying int value, which we can then modify or assign a new value to. However, when we dereference a pointer to a struct, we get a reference to the entire struct object, which is a more complex data type consisting of multiple values. Modifying or assigning a new value to a struct requires accessing or modifying its individual members, which cannot be accomplished simply by dereferencing a pointer. Instead, we must access and modify the members of the struct using the dot or arrow operators.
Asked: 2023-01-20 11:00:00 +0000
Seen: 9 times
Last updated: Nov 22 '21