C/C++ 结构体 指针 简单输入输出

 #include <stdio.h>
#include <stdlib.h> struct student{
int num;
char str[];
double dec;
}; int main(){
int n;
struct student *stu; scanf("%d", &n);
stu = (struct student *)malloc(n * sizeof(struct student)); for(int i = ; i < n; ++i){
scanf("%d%s%lf", &stu[i].num, stu[i].str, &stu[i].dec);
} printf("%d\n", n);
for(int i = ; i < n; ++i){
printf("%d %s %lf\n", stu[i].num, stu[i].str, stu[i].dec);
} free(stu);
return ;
}
/*
3
20 字符串0 20.02
21 字符串1 21.12
22 字符串2 22.22
*/
上一篇:基于HttpClient 4.3的可訪问自签名HTTPS网站的新版工具类


下一篇:Ubuntu配置Django+ Apache2+ mysql