strcpy函数

字符串拷贝函数:

1、char *strcpy(char *dest,const char *src) 将src中的数据拷贝到dest中,并返回dest的地址

2、如果dest长度够长,则一部分数据会被覆盖,多余的保留

3、dest应该开大一点,防止复制时溢出

 1 #include <iostream>
 2 #include <cstring> // 注意头文件
 3 using namespace std;
 4 int main()
 5 {
 6     char a[] = "abcd";
 7     char b[] = "bcde";
 8     cout << strcpy(a,b); // 输出结果:bcde
 9     return 0;
10 }

 

posted @ 2020-08-05 08:35  不敢说的梦  阅读(460)  评论(0)    收藏  举报