-
Structs and Error C2106
I receive error C2106 (Compiler Error C2106 (C++))
on these 2 lines:
Code:
data.buddy = buddyname;
data.message = "AAA";
these are the relevant declarations at the beginning of the method:
Code:
guchar buddyname[MAX_BUDDYNAME_LENGTH+1];
struct tapData data;
struct tapData *p = &data;
and this is my struct defined at the top of my code:
Code:
struct tapData {
char buddy[20];
char message[200];
};
the guchar buddyname is set in the code. I'm confused as to why I can't assign either value?
-
I'm a bit confused myself. Why are you posting this in the C forum, instead of the C++ forum?
-
Because you can't assign to arrays. To put characters into a character array, use strcpy or similar.
-
As the poster said:
Code:
strcpy(data.message,"AAA");
This copies the string AAA into data.message, and appends the null at the end of the 3 characters.
------------
Beginner Computer Programming
teaching computer programming to beginners using C
-
-
Ignore, I can't spell or read. X.X