warning: deprecated conversion from string constant to ‘char*’
Posted modiqiang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了warning: deprecated conversion from string constant to ‘char*’相关的知识,希望对你有一定的参考价值。
原因:
函数的形参原型为char *str,表示传递一个字符串的地址过来,并且可以通过传递过来的地址来修改其中的值;但是我传递的只不过是一个字符串常量,所以弹出了这个警告
而加了const之后:
改为const char *str,因为有const修饰符,变代表指针s指向的值不能被修改,符合字符串常量不能被改变的特性;
参考:https://www.cnblogs.com/tolic/p/7142268.html
ps:怖い!マジ怖い!video
以上是关于warning: deprecated conversion from string constant to ‘char*’的主要内容,如果未能解决你的问题,请参考以下文章