Reputation: 204
Im trying to assign a array to my letter.charData but i get this error:
IntelliSense: expression must be a modifiable lvalue
Im trying to add my array arr to letter.charData
Thanks in advance!
struct _Letter{
char character;
int width;
int charData[8][5];
};
typedef struct _Letter Letter;
Letter *allocLetter(void)
{
Letter *letter;
letter = (Letter*) malloc(1 * sizeof(Letter));
letter->character = NULL;
letter->width = NULL;
/* charData? */
return letter;
}
int main(void)
{
Letter letter = *allocLetter();
int arr[8][5] =
{
0,0,0,0,0,
1,0,0,0,0,
1,0,0,0,0,
1,0,0,0,0,
1,0,0,0,0,
1,0,0,0,0,
1,0,0,0,0,
1,0,0,0,0
};
letter.character = '1';
letter.charData = arr;
return(0);
}
Upvotes: 1
Views: 1444
Reputation: 363817
_Letter::charData
is an array, not a pointer, so you can't just assign another array to it. Either copy arr
's contents into it with memcpy
, or change its type to a pointer:
typedef struct {
char character;
int width;
int (*charData)[5];
} Letter;
Also,
_
followed by a capitalNULL
should only be used for pointers; use '\0'
for characters, plain 0
for integersmalloc
for nullUpvotes: 5