uint32_t after = 0xe1ca95ee;
char new_buf[4];
memcpy(new_buf, &after, 4);
printf("%x\n", *new_buf); // I want to print the content of new_buf
I want to copy the content of after
to new_buf
. But the result is confusing. printf
gives me ffffffee
. It looks like an address. I have already dereferenced new_buf
.
According to the comments, I can't use memcpy
or strncpy
to do this task. But why? memcpy
and strncpy
are only designed to handle char *
? But the content of after
is in memory.
PS: I know I should use sprintf
or snprintf
. If you can explain why memcpy
and strncpy
is not for this case, I appreciate it.