结构体成员: 为变量只能定义一个字符,定义为指针 可以存放多个字符(字符串)
#include <stdio.h> struct Foo { char *a; // 指针可以存放多个字符串,变量只能存一个 int b; double c; }foo1, foo2; //define two structs with three different fields void struct_assign(void) { foo2 = foo1; //structure directly assignment } int main() { foo1.a = "eisc is 结构体字符串 "; foo1.b = 1; foo1.c = 3.14; struct_assign(); // 函数 将结构体 1 赋值 给 2 printf("%s %d %lf\n", foo2.a, foo2.b, foo2.c); // 写入的是 1 读取的是 2 , 由于前赋值相等原因 1 和 2 相等 return 0; }