I'm not a C++ programmer, so I need some help with arrays. I need to assign an array of chars to some structure, e.g.
struct myStructure {
char message[4096];
};
string myStr = "hello"; // I need to create {'h', 'e', 'l', 'l', 'o'}
char hello[4096];
hello[4096] = 0;
memcpy(hello, myStr.c_str(), myStr.size());
myStructure mStr;
mStr.message = hello;
I get error: invalid array assignment
Why it doesn't work, if mStr.message and hello have the same data type?
hello[4096] = 0;is wrong. This is one past the last element of the array. Just remove this line.