In my course on C++ is used this initialization.
char *a = "abcd";
However, when I use it, a compiler complains:
a value of type "const char*" cannot by used to initialize an entity of type "char*"
*a should be pointer. What is a problem please? I use Visual Studio 2017
You need to specify const
const char *a = "abcd";
The reason is that the string "abcd" is a constant and thus should not be assigned to a non const pointer. It was tolerated in old C++ (AFAIK), but since C++11, it's not, and VS2017 with /permissive- does the right thing and forbids this bad practice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With