#include <stdio.h> struct student{ int ID; char name[48]; int age; }; int main(){ struct student s1 = { 1, "lifei", 24 }; struct student s2; s2 = s1; //s2.name = "letben";//错误 1 error C2106: “=”: 左操作数必须为左值 f: ryc++结构体的赋值结构体的赋值main.c 15 1 结构体的赋值 //所以在底层我们的结构赋值语句中关于字符数组的操作被改写成了字符串拷贝命令。 strcpy(s2.name, "letben"); s2.ID = 2; s2.age = 25; printf("s2的基本信息:学号:%d,姓名:%s,年龄:%d", s2.ID, s2.name, s2.age); getchar(); return 0; }