5 ms·
C string literals are " char * ". C++ string literals are " const char * " (one of the minor incompatibilities between the languages). They ought to be "const
by smitherfield 10y ago
C string literals are " char * ".
C++ string literals are " const char * " (one of the minor incompatibilities between the languages).
They ought to be "const char[]" but aren't. And, the behavior of "char[]" should be the same as "struct { char[] }", but it isn't.
- gpderetta 10y agoThey actually are proper arrays in C++ [1], although, as usual, they decay to pointers faster than an unstable particle. [1]: https://godbolt.org/g/ZWISCu https://godbolt.org/g/ZWISCu
- smitherfield 10y agoI stand corrected!