27 lines
527 B
C
27 lines
527 B
C
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
typedef struct Node{
|
|
int id;
|
|
char name[20];
|
|
} student;
|
|
|
|
//! 结构体变量的复制 基本数据类型可以复制 数组都可以复制 而不是 只复制数组的地址
|
|
int main(void){
|
|
|
|
student s1, s2;
|
|
s1.id = 1;
|
|
strcpy(s1.name, "LH");
|
|
|
|
s2 = s1;
|
|
printf("s1:%d %s\n", s1.id, s1.name);
|
|
printf("s2:%d %s\n", s2.id, s2.name);
|
|
|
|
s2.name[0] = 'A';
|
|
|
|
printf("s1:%d %s\n", s1.id, s1.name);
|
|
printf("s2:%d %s\n", s2.id, s2.name);
|
|
|
|
|
|
return 0;
|
|
} |