warning: deprecated conversion from string constant to ‘char*’?
I got this warning from the compiler:
Quote:
warning: deprecated conversion from string constant to ‘char*’
when I tried to pass a string constant to a function that has a char* input argument. Something like
Quote:
myfunction("my string");
What's the correct way to do this? Thanks!
Re: warning: deprecated conversion from string constant to ‘char*’?
C89 introduced the const keyword. String literals are now considered const char *s. To preserve backwards compatibility, they allowed implicit conversion between string literals and char *, but it's deprecated. It's safe to say it will not be removed in the next standard though as there are still tons of libraries that do it.