【问题标题】:invalid types ‘unsigned char[int]’ for array subscript [closed]数组下标的无效类型“unsigned char [int]”[关闭]
【发布时间】:2014-07-09 15:41:33
【问题描述】:

我正在尝试使用数据字节创建 CRC,并且我已经编写了这个函数:

u16 crcGenerate(unsigned char bytes, int len){
u16 crc = 0;
for (int i = 0; i < len; i++){
    crc = crc16__computeByteAnsi(crc, bytes[i]); }
    return crc;
}

每当调用此函数时,我都会不断收到上述错误,我不太确定如何修复它,甚至不知道出了什么问题。

为避免使这个问题变得臃肿,我已经包含了引用的其他主要 .h 和 .cpp 文件。

This is the Command header file (cmgCOM.h)

This is where the CRCs are computed (crc16.cpp)

This is the primary Command file (cmgCOM.cpp)

我非常感谢我能得到的任何帮助;如果需要提供更多信息,请告诉我。我对 C/C++ 不是很熟悉,也不知道是什么导致了这个问题。

谢谢。

【问题讨论】:

  • 您缺少*。你想要unsigned char *bytes

标签: c++ c arrays types crc


【解决方案1】:

我认为您希望 bytes 成为一个 unsigned char 数组,但您只将其标记为单个 unsigned char 值。

u16 crcGenerate(unsigned char bytes[], int len){

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-05-05
    • 2022-12-09
    • 2021-02-25
    • 2010-09-26
    • 2012-09-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多