由于C++表中的表编译错误
问题描述:
我试图通过串口为TI-Nspire Calc创建一个聊天程序。所以我安装了ndless SDK和nspireio LIB使通信和它种工作,因为有消息的infite重复,所以我写了这个:由于C++表中的表编译错误
if(uart_ready()) {
char input[100] = {0};
uart_getsn(input,100);
if(oldinput != input) {
nio_puts(input);
oldinput = input;
}
}
但是,当我编译它给我这个错误:
[email protected]:~/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);
答
如果oldinput也是一个字符数组,
与
strcpy(oldinput,input);
+1
这假定以空字符结尾。 IO的情况很少。 – 2017-10-14 15:36:48
+0
更正确的: memcpy(oldinput,input,sizeof(char)* 100); –
其中定义的变量替换oldinput
oldinput=input
? – farbiondriven提示:使用'export LANG = C LC_ALL = C'来获取您的英文讯息 –
它已经在 – TurtleForGaming