gpt4 book ai didi

c - 海湾合作委员会错误 : Invalid operands to binary +

转载 作者:行者123 更新时间:2023-12-04 09:39:30 27 4
gpt4 key购买 nike

为什么 GCC 给我这个错误?我在这里做错了什么?

 temp.c: In function main:
temp.c:6: error: invalid operands to binary +

代码:

 main()
{
char *Address1,*Address2,*NewAddress;
Address1= (char*)0x12;
Address2= (char*)0x34;
NewAddress = Address1+Address2;
}

最佳答案

为什么要这样做?

C语言禁止两个指针相加。它只定义(有严格限制)指针和整数的加法。

基本上,您只能向指针添加一个足够小的整数,以便结果位于某个已分配内存区域的内部或结束边界处。

关于c - 海湾合作委员会错误 : Invalid operands to binary +,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8579467/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com