由于C ++中的表导致编译错误 [英] Compilation error due to table in C++

查看:98
本文介绍了由于C ++中的表导致编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过串行端口为TI-Nspire Calc创建一个聊天程序。因此,我安装了ndless SDK和nspireio lib进行通讯,并且这种方式行之有效,因为消息反复重复,所以我这样写:

I'm trying to create a chat programm for the TI-Nspire Calc via the serial port. So I installed the ndless SDK and nspireio lib to make the communication and it kind of works because there is an infite repetition of the message so I wrote this:

if(uart_ready()) {
    char input[100] = {0};
    uart_getsn(input,100);
    if(oldinput != input) {
            nio_puts(input);
            oldinput = input;
    }
 }

但是在编译时会出现以下错误:

But when I compile it give me this error:

root@Kali-Linux:~/TINSPIRE/Ndless/ndless-sdk/samples/uart# make
nspire-g++ -Wall -W -marm -Os -c hello.cpp
hello.cpp: Dans la fonction « int main() »:
hello.cpp:61:14: error: affectation de tableau invalide
   oldinput = input;
              ^~~~~
Makefile:33 : la recette pour la cible « hello.o » a échouée
make: *** [hello.o] Erreur 1

我在做什么错了?

推荐答案

您应该声明 oldinput

char oldinput[100] = {0};

memcpy(oldinput, input, sizeof(char) * 100); 

这篇关于由于C ++中的表导致编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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