是全局变量与局部变量的问题吗
int AI,AII,AIII,x;double TJ={AI,AII,AIII};
int TJBH={1,2,3};
void setup()
{
Serial.begin(9600);
}
void KZDJ()
{
for(int i = 0; i < 3 ; i++)
{
x=int((TJ+500)+0.5);
Serial.print("#");
Serial.print(TJBH);
Serial.print("P");
Serial.print(x);
}
}
void loop()
{
AI=4.4,AII=5.7,AIII=6.3;
KZDJ();
}
不明白结果为什么不是#1P504#2P506#3P506
而是#1#1P500#2P500#3P500
恳请大侠们指点一二 ->double TJ={AI,AII,AIII};
改成使用指针数组,程序有若干地方要改
建议LZ看一下C语言教程(比如K&R C),有关指针的部分:lol 楼主你定义了整型的变量,用的时候却是浮点型的!
double TJ={0.0,0.0,0.0};就可以了
我先拿一个简单的例子 实验指针数组
int a=1,b=2,c=3;
int *p;
p=&a;
p=&b;
p=&c;
但为什么自检报错啊
sketch_sep20b:2: error: expected constructor, destructor, or type conversion before '=' token
sketch_sep20b:3: error: expected constructor, destructor, or type conversion before '=' token
sketch_sep20b:4: error: expected constructor, destructor, or type conversion before '=' token
我真的没办法了 大侠们给个例子让我学学吧:'( int *p = { &a, &b, &c };
申明全局变量同时初始化赋值应该这么写
页:
[1]