Hi folks,
I use memcpy to copy a content from a memory location to another
Code:
#include <stdio.h>
#include <string.h>
int main ()
{
char str1[]="Sample string";
char str2[40];
char str3[40];
memcpy (str2,str1,strlen(str1)+1);
memcpy (str3,"copy successful",16);
printf ("str1: %s\nstr2: %s\nstr3: %s\n",str1,str2,str3);
return 0;
}
Printf will show the exact same "Sample String" as expected, but if i change printf to
Code:
printf ("str1: %X\nstr2: %X\nstr3: %X\n",str1,str2,str3);
I get something like
str1: BFBF4962
str2: BFBF493A
I thought the content should be similar? Can anyone help explain it to me please?
Thanks in advanced.