Home Segments Index Top Previous Next

391: Mainline

A writer is a function that inserts information into an object. When you use writers, rather than writing into structure variables directly, you can include additional computation in a writer. Earlier, in Segment 389, you saw how to add a statement to the read_trade_price reader that announces each access. The following provides the same enhancement to the write_trade_price writer:

void write_trade_price (double price, struct trade *tptr) { 
  printf ("Writing a trade price ...\n"); 
  tptr -> price = price; }