M
Mark
Hello
consider the code:
struct {
int a;
int b;
} p1[] = {
{0,1}, {0,2}, {0,3},
{-1,-1}
};
....
Is there a way to re-assign the structure later, say something like:
if (some_condition) {
p1[] = { {1,1}, {2,2}, {3,3}, {4,4}};
}
I tried to typedef a new type, but with no luck and with compiler's error:
typedef struct p{
int a;
int b;
} p;
p p1[] = {
{0, 1}, {0, 2}, {0, 3},
{-1, -1}
};
....
p p2[] = {{1,2}, {3,4}, {5,6}, {7,8}};
p1 = p2; /* Error: incompatible types in assignment */
What am I missing ?
Thanks in advance.
consider the code:
struct {
int a;
int b;
} p1[] = {
{0,1}, {0,2}, {0,3},
{-1,-1}
};
....
Is there a way to re-assign the structure later, say something like:
if (some_condition) {
p1[] = { {1,1}, {2,2}, {3,3}, {4,4}};
}
I tried to typedef a new type, but with no luck and with compiler's error:
typedef struct p{
int a;
int b;
} p;
p p1[] = {
{0, 1}, {0, 2}, {0, 3},
{-1, -1}
};
....
p p2[] = {{1,2}, {3,4}, {5,6}, {7,8}};
p1 = p2; /* Error: incompatible types in assignment */
What am I missing ?
Thanks in advance.