Try this:
char* buf = "12345";
char logbuffer[1024];
struct xx {
int a;
char b[1024];
};
xx yy;
strcpy(logbuffer, buf);
memcpy(yy.b, logbuffer, strlen(logbuffer));
char logbufferb[2][1024];
xx yyb[2];
strcpy(&logbufferb[1][0], buf);
memcpy(yyb[1].b, &logbufferb[1][0], strlen(&logbufferb[1][0]));
Note the above comments with respect to the
addressof
operator (
&
). Also note that using
memcpy
does not null terminate the strings, so you may have problems with it, always use
strcpy
.