Tag: 硬编码

C硬编码数组作为memcpy参数

我想传入一个硬编码的字符数组作为memcpy的source参数…这样的事情: memcpy(dest, {0xE3,0x83,0xA2,0xA4,0xCB} ,5); 这与clang编译给出了以下错误: cccc.c:28:14: error: expected expression 如果我修改它(见额外的括号): memcpy(dest,({0xAB,0x13,0xF9,0x93,0xB5}),5); clang给出的错误是: cccc.c:26:14: warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'const void *' [-Wint-conversion] cccc.c:28:40: error: expected ';' after expression memcpy(c+110,({0xAB,0x13,0xF9,0x93,0xB5}),5); 所以,这个问题: 如何传入硬编码数组作为memcpy的源参数( http://www.cplusplus.com/reference/cstring/memcpy/ ) 我努力了: (void*)(&{0xAB,0x13,0xF9,0x93,0xB5}[0]) – syntax error {0xAB,0x13,0xF9,0x93,0xB5} – syntax error ({0xAB,0x13,0xF9,0x93,0xB5}) – see above (char[])({0xE3,0x83,0xA2,0xA4,0xCB}) – […]