char* foo = "fpp"; //compile in vs 2010 with no problem
I though string literal is const char* type.
And const type cannot be assigned to non-const type.
So I expect the code above to fail or am I missing something?
Edit: Sorry guys, I totally forgotten that compiler throws warning too.
I was looking at error list all this time.
I’m forget to check that.
Edit2: I set my project Warning Level to EnableAllWarnings (/Wall) and there’s no warning about this.
So my question is still valid.
As I understand it, in C, before
constwas added, this was the way to assign a string to a pointer.In C++ this is deprecated behavior, but still allowed to keep backwards compatibility. So don’t use it.
In fact, I believe in C++11 it’s completely invalid.