I have the following code:
typedef struct Test {
long mem[1000];
} Test;
extern Test *test;
int main() {
Test *test = (Test *)malloc(sizeof(Test));
test->mem[0] = 1;
test->mem[1] = 2;
test->mem[2] = 3;
test->mem[3] = 4;
test->mem[4] = 5;
test->mem[5] = 6;
return 0;
}
It's working OK, but I want to change the initalization of the mem array to be in that way:
test->mem = {1,2,3,4,5,6};
But the gcc giving me this error:
error: expected expression before '{' token test->mem = {1,2,3,4,5,6}; With arrow pointing to the left open braces.
What it can be?
Thanks!
EDIT: I also try this code:
long mem[1000] = {1,2,3,4,5,6};
test->mem = mem;
And I'm getting this error from gcc:
error: incompatible types when assigning to type 'long int[1048576]' from type 'long int *' test->mem = mem;
I'm not allow to use any C functions.