Home Segments Index Top Previous Next

390: Mainline

You also can assign a structure variable's value indirectly by defining a function that assigns a value. In the following, for example, the definition of the write_trade_price function indicates that write_trade_price assigns a value to the price structure variables:

void write_trade_price (double price, struct trade *tptr) { 
  tptr -> price = price; 
} 

Inasmuch as the only purpose of the write_trade_price function is to assign a value to a structure variable, the write_trade_price function is marked void, indicating that no value is to be returned.