you cannot change the address of an array. It will give a compile time error. have a look: http://codepad.org/skBHMxU0
EDIT:
the comments made me realize your true intent:
something like:
char *ptr = "one two three";
ptr++;
There is no problem with it. the string "one two three" is a constant, and you can freely modify ptr
, but note you might have troubles later finding the start of this string again... [but memory leak will not occur]
As a thumb rule, you are responsible for the memory you specifically allocated using malloc/new, and the compiler is responsible for the rest.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…