strcpy函数:
用于字符串的复制,将后面的字符串赋值到前面
strncpy函数:
strncpy(p, p1, n) 复制指定长度字符串
#include <string.h>
char a[10];
strcpy(a, "hello");
#include <string.h>
struct StuData{ //结构体类型定义最好在h文件,结构体变量定义最好在C文件
char code[10];
char name[16];
char serial[30];
char password[30];
}stu[20];
void student_init()
{
strcpy(stu[0].code, "24F6D3EA");
strcpy(stu[0].name, "一号");
strcpy(stu[0].serial, "fe:88:06:5a:8d:49");
strcpy(stu[0].password, "abc111");
strcpy(stu[1].code, "44F6D3EA");
strcpy(stu[1].name, "二号");
strcpy(stu[1].serial, "46:aa:d5:56:f2:62");
strcpy(stu[1].password, "abc222");
}
memcpy函数:
用于数组的复制,与strcpy函数不同,它不追加对字符串结束符'\0'