Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
const char* = new char[6]
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Frederick Gotham, post: 2580758"] benben posted: That information is flawed. The first example does NOT contain any string literal whatsoever; it's just the syntax we use to conveniently initialise an array. The following two definitions are exactly equivalent: char str[] = "hello"; char str[] = {'h','e','l','l','o',0}; The second example however DOES contain a string literal. We know string literals to be of static storage duration, so we can say it's quite equivalent to: static char const literal_[] = {'H','e','l','l','o',0}; char (&literal)[sizeof literal_] = const_cast<char(&)[sizeof literal_]>(literal_); char const *p = literal; [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
const char* = new char[6]
Top