目前我正在将VLA分配给指针,如下所示
struct Foo {
int* array;
};
int array[size];
struct Foo foo = {
.array = array;
};
有可能用"匿名"数组替换它吗?
我try 过的是:
struct Foo foo = {
.array = (int[size]) {} // fatal error: variable-sized object may not be initialized
};
我所希望的是:
struct Foo foo = {
.array = int[size]; // something similar to this if I am making any sense.
};
PS:我不是在寻找动态内存分配(malloc/calloc).