c - Change non-modifiability of an array by using a structure -
from kerrek sb's comment on why can't modifiable lvalue have array type?
you can trivially assign arrays making them members of struct , assigning lvalues.
what mean? mean if structure has array member, array member can modifiable? following example doesn't work:
i define struct type member being array
typedef struct { int arr[3];} mytype;
then
mytype mystruct; mystruct.arr = (int[]) {3,2,1};
and got error: assignment expression array type
.
no, means if assign instance of struct
1 in example struct
assigning arrays.
struct array { int array[3]; }; struct array a; struct array b = {{0, 1, 2}}; // chris dodd // valid! = b;
Comments
Post a Comment