Let's say you have a string like this:
char* a="01234"
Letting &a=0000, &(a+1)=0001, &(a+2)=0002, and so on, what happens if there is some memory already allocated for another variable at 0007, and you try resizing a to a larger size (a="0123456789")? Will a move to a new location that can fit the larger string, or will the data in 0007 be overwritten?
Edit:
I don't understand what people mean when they say resizing C-style strings is not allowed.
char* a="01234"
cout << &a; //Prints 00FF1360
cout << a; //Prints 01234
a="0123456789"
cout << &a; //Still prints 00FF1360
cout << a; //Prints "0123456789"
The pointer a didn't change at all when I reassigned it. It seems like the original string "01234" was just destroyed and "0123456789" replaced it in the same location.
Nevermind, I was printing the location of the pointer rather than the location it was pointing to. As a side question, does anyone know how to print a character pointer's value without it printing the string instead?