警告:赋值时将指针整数,未作投 [英] warning: assignment makes integer from pointer without a cast
本文介绍了警告:赋值时将指针整数,未作投的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我宣布一个的char *
来固定字符串和重用的指针指向另一个字符串
When I declare a char *
to a fixed string and reuse the pointer to point to another string
/* initial declaration */
char *src = "abcdefghijklmnop";
.....
/* I get the "warning: assignment makes integer from pointer without a cast" */
*src ="anotherstring";
我试图重铸指针,但没有成功。
I tried to recast the pointer but no success.
推荐答案
这位前pression * SRC
指的是字符串中的第一个字符,而不是整个串。要重新分配的src
来指向一个不同的字符串 TGT
,使用 SRC = TGT;
。
The expression *src
refers to the first character in the string, not the whole string. To reassign src
to point to a different string tgt
, use src = tgt;
.
这篇关于警告:赋值时将指针整数,未作投的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文