【发布时间】:2011-07-04 13:56:26
【问题描述】:
当我将char * 声明为固定字符串并重用指针指向另一个字符串时
/* initial declaration */
char *src = "abcdefghijklmnop";
.....
/* I get the "warning: assignment makes integer from pointer without a cast" */
*src ="anotherstring";
我试图重铸指针但没有成功。
【问题讨论】:
-
在 C 中不推荐使用非 const
char*指向字符串常量——您应该将src更改为const char*类型。