Members of Structs
Members of Structs

To access the members of the struct we declared in the previous example:

struct book new; ... we would use the "dot operator". Here's how it would look if we only wanted to access one portion of the struct at a time:
new.author - This would be a string to which we have assigned the name of the author of the book new.
new.price - would give us a floating point number and so on..
new.edition
new.title
new.callNumber
To assign values into a struct, you would access them as shown above and then treat them as if they were a regualr variable of that type. Here are a few examples: new.name = "Anne McCaffery"; new.price = 6.99; You can also assign on struct to another as follows: struct book original = new; Now all the information held in the struct called new is also stored in a struct called original. Very useful!


Main Page
Last Modified 17 October 2000