Home Segments Index Top Previous Next

389: Mainline

A reader is a function that extracts information from an object. When you use readers, rather than accessing structure variables directly, you can include additional computation in a reader. For example, if you were concerned about how often your program accesses the price structure variables in trade structures, you could add a statement to the read_trace_price reader that announces each access:

double read_trade_price (struct trade *tptr) { 
  printf ("Reading a trade price ...\n"); 
  return tptr -> price; 
}