为什么我收到错误消息,在'for'之前应收到非限定 id
Why am I getting the error message, expected unqualified id before 'for'
我必须为大学作业编写一个这样的代码。我已经编写了代码的平均函数,但我收到了另一个函数的错误消息。DEVBARD_read加速计功能将读取加速度的x、y、z分量
首先,您需要编写一个函数:int average(int*array,int nLen(;其返回整数值数组的平均值。(为了防止溢出,建议使用长的内部变量(。精神等级功能将运行一个循环。对于每次迭代,重力加速度的Z分量将以50ms的间隔采样四次,并存储在适当大小的阵列中。使用您编写的average((函数,确定平均值并分析
int average(int* array, int nlen) { // assuming array is int
long sum = 0L; // sum will be larger than an item, long for safety.
for (int i = 0; i < nlen; i++) {
sum += array[i];
}
return ((long)sum) / nlen;
}
float sum[3];
int j;
for (int j = 0; j < 3; j++) {
i = DEVBOARD_readAccelerometer(int* xAccel, int* yAccel, int* zAccel);
sum[j] = int * zAccel;
}
average(float* sum[j], float nlen);
printf("The average zcomponent is %fn");
}
unqualified-id before for
您声明了变量j
两次。在for循环的之前有一个,在for定义的内有一个。
相关文章:
- "error: no matching function for call to"构造函数错误
- 表示"accepting anything for this template argument" C++概念的通配符
- 如何在C++中从两个单独的for循环中添加两个数组
- 在Linux for Windows上编译C++代码时出错
- 调用专用模板时出错"no matching function for call to [...]"
- 为什么我的for循环不能正确获取argv
- 为什么我不能在 FOR LOOP 中使用 i/10,C++?
- Arduino:for/while/if在void setup()或void loop()之前?——错误:之前需要不合格
- 在基于范围的for循环中使用结构化绑定声明
- 通过for循环使用用户输入填充列表
- 使用for循环检查数组中的重复项
- 在for循环中使用auto vs decltype(vec.size())来处理字符串的向量
- 为什么 const std::p air<K,V>& 在 std::map 上基于范围的 for 循环不起作用?
- 正在使用for循环创建QScatterSerie
- Python中的for循环与C++有何不同
- std::memory_order for std::atomic:<T>:wait
- 为什么我收到错误消息,在'for'之前应收到非限定 id
- c++ for 循环中预期的非限定 id 错误
- 错误:"for"之前应为非限定 id。编译由于 -Wfatal 错误而终止
- 使用映射类型会产生GCC错误:预期的未限定id在' for '之前