Warnings - deprecated conversion from_string constant char* - 2020
bogotobogo.com site search:
So, what should we do?
We have 3 options:
- We need to change the char * to const char *
We should assign all string literals to a pointer of type const char *, which ensures that they cannot be accidentally written to.const char *x = "i_am_a_string_literal";
- We may want to cast the string literal to type char *
char *x = (char *)"i_am_a_string_literal";
- We can use a string instead of a pointer to a character
string x = "i_am_a_string_literal";
bogotobogo.com site search:
Ph.D. / Golden Gate Ave, San Francisco / Seoul National Univ / Carnegie Mellon / UC Berkeley / DevOps / Deep Learning / Visualization