Open main menu

CDOT Wiki β

Changes

C/C++ FAQ

8 bytes removed, 14:17, 19 September 2012
no edit summary
<br>
'''Q:''' When using square-bracket pointer arithmetic, does ptr[-k] decrement the pointer?<br>
'''A:''' Yes. 'ptr' is the address of an element of the array; the array's element size is multiplied by the value of 'k', negated by '-', and then 'added' (in practice subtracted) to the address stored in 'ptr'. ptr[-k] moves to the element 'k ' elements earlier than the element pointed to by ptr.