Open main menu

CDOT Wiki β

Changes

C/C++ FAQ

233 bytes added, 09:55, 19 September 2012
C/C++ FAQ
----
<br>
'''Q:''' When using square-bracket pointer notationarithmetic, does ptr[-k] decrement the pointer?<br>'''A:''' Yes. Detailed answer forthcoming'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 k elements earlier than the element pointed to by ptr.<br><br>