Thread: char[] vs char*
View Single Post
Old Apr 13th, 2008, 10:30 PM   #9
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 856
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
Re: char[] vs char*

Quote:
Originally Posted by Narue View Post
When you initialize an array with a string literal, a copy of the string literal is stored in the array. You own the memory for the array, therefore you can modify the copy of the string literal (provided it's not declared as const). When you initialize a pointer with a string literal, the pointer points to the string literal itself. The reason you can't use b to modify the string literal is because string literals are read-only.
Does anyone know of an official source where I can find this information? (A link would be appreciated.) Thanks.
titaniumdecoy is offline   Reply With Quote