如何在struct inline中指定char数组?

d0c*_*age 6 c++ arrays struct inline declare

我正在尝试做这样的事情:

struct SomeStruct {
    const char *bytes;
    const char *desc;
};

SomeStruct example = { { 0x10, 0x11, 0x12, 0x13 }, "10-13" };
Run Code Online (Sandbox Code Playgroud)

为什么这不起作用?

Ben*_*oit 8

可能是因为{ 0x10, 0x11, 0x12, 0x13 }是一个数组char,而不是指针char.

试试吧SomeStruct example = { "\x10\x11\x12\x13", "10-13" };.