#define _CRT_SECURE_NO_WARNINGS标签:arr,sscanf,name,age,printf,st,sprintf,使用,st1 From: https://blog.51cto.com/u_13606048/6129753
#include<stdio.h>
struct stu {
int age;
char name[1024];
};
int main() {
struct stu st = { 25,"LiMing" };
struct stu st1 = { 0 };
char arr[1024] = { 0 };
//整合到一起
sprintf(arr, "%d %s", st.age, st.name);
//统一输出
printf(arr);
printf("\n");
//把整合到一起的arr拆散开,放到同样的结构体st1中
sscanf(arr,"%d %s",&(st1.age),st1.name);
printf("%d %s", st1.age, st1.name);
return 0;
}