Home Segments Index Top Previous Next

384: Mainline

In Chapter 22, you learned how to obtain an address for a chunk of memory allocated at run time:

(struct trade*) malloc (sizeof (struct trade)) 

Such an expression is a load to remember. Worse yet, you need to assign the address of the allocated chunk of memory to a pointer, and you have to assign the structure variables appropriately:

trade_pointers[limit] = (struct trade*) malloc (sizeof (struct trade)); 
trade_pointers[limit] -> price = price; 
trade_pointers[limit] -> number = number; 

Such allocation and assignment combinations are cumbersome and ugly.