Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我遇到了 typedef 的问题。
typedef char cool_array_t[ARRAY_SIZE]; cool_array_t* out; // do stuff with out cool_array_t test = *out;
我得到的错误如下:
从类型“char *”分配给类型“cool_array_t”时类型不兼容</p>
我尝试投射到cool_array_t,但它给出了以下错误:
错误:强制转换指定数组类型
您不能分配给数组。您需要使用memcpy或包装struct。
memcpy
struct
struct cool_array_t { char data[ARRAY_SIZE]; }; struct cool_array_t* out; // do stuff with out struct cool_array_t test = *out;