Home Segments Index Top Previous Next

349: Mainline

You also know that you can increment pointer variables. Suppose that you define a trade pointer as follows:

struct trade *tptr; 

Then, you can initialize and increment the pointer, along with the counter, such that the pointer identifies successive addresses of the elements in the array:

for (counter = 0, tptr = trades; counter < limit; ++counter, ++tptr) 
  sum = sum + trade_price(tptr);