说明
字符串复制,遇到’\0’就停止
函数原型
char *strcpy(char *dest, const char *src)
参数
- dest 指向用于存储复制内容的目标数组
- src 要复制的字符串
返回值
该函数返回一个指向最终的目标字符串 dest 的指针
例子
#include <stdio.h>
#include <string.h>
int main()
{
char s[30];
strcpy(s, "This is a strcpy example.");
for (unsigned long i=0; i<strlen(s);i++)
{
printf("%c", s[i]);
}
printf("\n");
return 0;
}