GCC错误:无效操作数为二进制+ [英] GCC Error: Invalid operands to binary +

查看:301
本文介绍了GCC错误:无效操作数为二进制+的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

  temp.c:在主函数:
 temp.c:6:错误:无效的操作数为二进制+

code:

 的main()
 {
     字符*地址1 *地址2,* NewAddress;
     地址1 =(字符*)0×12;
     地址2 =(字符*)0x34;
     NewAddress =地址1 + 1地址;
 }


解决方案

你为什么要这么做?

C语言禁止另外两个指针的。它只定义(有严格的限制)增加了一个指针和一个整数。

基本上,你只能添加到一个指针整数足够小,这样的结果在里面,或者在结束边境,一些分配的内存区。

Why is GCC giving me this error ? What am I doing wrong here ?

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

Code:

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

解决方案

Why do you want to do that?

The C language forbids addition of two pointers. It only defines (with severe restrictions) the addition of a pointer and an integer.

Basically, you can only add to a pointer an integer small enough so that the result was inside, or at the ending border, of some allocated memory zone.

这篇关于GCC错误:无效操作数为二进制+的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆