Hi folks,
I use memcpy to copy a content from a memory location to another
Printf will show the exact same "Sample String" as expected, but if i change printf toCode:#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; }
I get something likeCode:printf ("str1: %X\nstr2: %X\nstr3: %X\n",str1,str2,str3);
str1: BFBF4962
str2: BFBF493A
I thought the content should be similar? Can anyone help explain it to me please?
Thanks in advanced.



LinkBack URL
About LinkBacks



