Does this…
char* myString = "hello";
… have the same effect as this?
char actualString[] = "hello";
char* myString = actualString;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No.
The first example creates an array of size
13*sizeof(char)on the stack and copies the string"Hello world!"into it.The second example creates a
char*on the stack and points it to a location in the data-segment of the executable, which contains the string"Hello world!". This second string is READ-ONLY.