O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Accessing Data

Data stored in a struct or union is accessed member by member. So if you needed to copy one object to another, with both having the same type (a user-defined struct, for example), you would need to do so member by member. If one happens to be a struct, then it too must be copied member by member.

Accessing a member of a struct or union is accomplished in the following way:

variable_name.member_name

This code assumes that you have defined a variable of a specific type in variable_name, and that it is a struct or union. You’ll learn about the specific concerns of union data member access later; for now, let’s look at structs specifically.

You saw this originally in the definition of the data type tm for use with the various standard ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required