声明字节数组时出现 C++ 语法错误

标签 c++ arrays syntax constants byte

我试图声明一个字节数组,这样我就可以遍历它们并分别使用它们中的每一个。这是数组

const BYTE keybyte[] = {
    0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
    0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
    0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57 0x58,
    0x59, 0x5A, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35,
    0x36, 0x37, 0x38, 0x39, 0x25, 0x27, 0x26, 0x28,
    0x0D, 0x20, 0x10, 0x11, 0x12, 0x18};

出于某种原因,当我编译它时会出现这些错误:/

error C2143: syntax error : missing '}' before 'constant'
error C2143: syntax error : missing ';' before 'constant'
error C2059: syntax error : 'constant'
error C2143: syntax error : missing ';' before '}'
error C2059: syntax error : '}'

我不明白,因为如果我把它换成

const BYTE keybyte[] = {0,0,0,0};

它工作得很好,没有错误:/?

最佳答案

0x570x58 之间缺少逗号。

关于声明字节数组时出现 C++ 语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6864483/

相关文章:

C++ Windows API : disabled menu grayed?

C 中的条件语句和数组(初学者)

java - 将混合数组中的值相乘

arrays - 数组中的 Fortran 数组

javascript - 语法错误-语句前遗漏

c++ - boost 图是否正在切片我的 shared_ptr

c++分配* new Object()以引用

c++ - GDB 可以调试 C++ lambdas 吗?

c++ - 如何理解 `Color (&EnumValuesColor())[3] {…}`语法?

C++ const 关键字 - 随意使用?