c语言面试字符串复制
1,下面这个函数的打印是什么:
#include<stdio.h>
#include<string.h>
int main()
{
char str0[5], str1[] ="welcome";
strcpy(str0, str1);
printf("str0:%s\r\n",str0);
printf("str1:%s\r\n",str1);
}
lark@lark-VMware-Virtual-Platform:~/public/mianshi$ ./pointer1
str0:welcome
str1:me
printf("pstr0:%p\r\n", str0);
printf("pstr1:%p\r\n", str1);
pstr0:0x7fff84e4a44b
pstr1:0x7fff84e4a450
地址分析:
所以 str1的数据是me.