These answers are correct.
Note that if you have a function that requires an array of characters as an argument, and you pass this argument as follows:
foo ("bar");
The same warning will be shown. In this case, you can:
1) Change it as described in the first answer:
void foo (char[] str) { printf(str); } const char param[] = "bar"; foo (param);
2) Consider a standard C ++ string, for example:
void foo (std::string theParam) { std::cout << theParam; } foo ("bar");
IMHO, if there is no real performance problem and you are not working with C libraries, or if you are creating a C ++ library for other users, you are better off working with immutable C ++ strings and their set of functions.
If you want to use Unicode, C ++ support is "terrible" as described here . This question gives you some hints (mainly: using the IBM ICU library). If you already have Qt in your project, QString also do the trick as well as Gettext.
tiktak Jul 08 '14 at 12:25 2014-07-08 12:25
source share