Comments

[b][red]This message was edited by stober at 2005-8-8 11:39:4[/red][/b][hr]: 5.) Assuming vPtr points to values[ 4 ], what address is referenced by vPtr -= 4. What value is stored at that location?: the answer depends on how is vPtr defined? Pointers are incremented and decremeneted by the size of the object to which they point. On a 32-bit compiler where sizeof(int) = 4, then vPtr -= 4 will decrement the pointer by 16 bytes. So the answer to the queation is that vPtr will point to &values[0].[code]vPtr - (4 * sizeof(int)) = vPtr - (4 * 4) = (address of vPtr) - 16assume vPtr = 10000 then vPtr -= 4 will result in address 10000 - 16.[/code]

: : 5.) Assuming vPtr points to values[ 4 ], what address is referenced by vPtr -= 4. What value is stored at that location?: : : the answer depends on how is vPtr defined? Pointers are incremented and decremeneted by the size of the object to which they point. On a 32-bit compiler where sizeof(int) = 4, then vPtr -= 4 will decrement the pointer by 16 bytes. [red]So the answer to the queation is that vPtr will point to &values[0].[/red]: [code]: vPtr - (4 * sizeof(int)) = vPtr - (4 * 4) = (address of vPtr) - 16: assume vPtr = 10000 then vPtr -= 4 will result in address 10000 - 16.: [/code]

[red]if the type of [blue]*vPtr[/blue] and [blue]*values[/blue] are same and [blue]vPtr[/blue] points to [blue]values[4][/blue], then after executing [blue]vPtr -= 4[/blue], [blue]vPtr[/blue] will always point to [blue]&values[0][/blue], isnt it?[/red]

: : [red]if the type of [blue]*vPtr[/blue] and [blue]*values[/blue] are same and [blue]vPtr[/blue] points to [blue]values[4][/blue], then after executing [blue]vPtr -= 4[/blue], [blue]vPtr[/blue] will always point to [blue]&values[0][/blue], isnt it?[/red]: :

Yes -- vPtr will point to values[0], the address stored in vPtr will be the same as &values[0].

: 1.) Print the elements of array values using pointer/offset notation. : : ANS: for ( i = 0; i < SIZE; i++ ) : printf("%.1f", [red]*(values + i)[/red] );: : is it right now? how about the other ones?: