Just to add on to previous comments
sizeof(x->A)
is correct sizeof(*x->A)
is not correct because ->
has higher precedence than *
so first the address of A is obtained(X->A) then *
again deference's it to first byte (one char byte).
Not to forget sizeof operator doesn't consider '\0'
character. if the the string "Hello"
is pointed by A then it returns 5 ( array size is 6 including '\0'),
so while copying to B
you have to add '\0'
explicitly or you can increase the number bytes to be copied by one as shown below.
memcpy(x->A, B, sizeof(x->A) + 1);