Access the answers to your technology questions today.
Subscribe Now
30-day free trial. Register in 60 seconds.
What Makes Experts Exchange Unique?
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.
Try it out and discover for yourself.
Subscribe Now
30-day free trial. Register in 60 seconds.
Join the Community
Give a Little. Get a Lot.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Join the Community
by: zebadaPosted on 2003-01-24 at 12:37:37ID: 7803220
y[1]= *(OL_out + ol_count_out);
le));
Using pointer arithmetic to calculatea memory location.
Whatever the sizeof(*OL_out) is then add that many bytes multiplied by ol_count_out to OL_out and get the value at that memory address and place that value into y[1].
i.e. Assuming OL_out is declared as a double * like this:
double *OL_out;
If the pointer value of OL_out is say, 0x00001234
and if ol_count_out is say, 5 then the value of
*(OL_out+ol_count_out) is the value of the memory location: 0x00001234+(5*8) = 0x0000125C since sizeof(double) is 8 bytes. So the double value that is stored at memory location 0x0000125C will be placed into the y[1] array element.
OL_out = (double *)malloc(10000*sizeof(doub
This statement allocates 10,000 * 8 bytes of memory since sizeof(double) is 8 bytes.
And sets the OL-out pointer to the memory address of the first byte of the allocated memory.
Regards
Paul