【发布时间】:2020-09-13 10:24:24
【问题描述】:
我有一个包含与此类似的文本的文本文件:
01234 Johnathan Doe 1 RG
12345 简·多伊 3 OC
我的问题是:如何定义一个可以包含文件中包含的信息的结构,使用一个数组(结构)来存储从文件中读取的数据? 当然文件是连续给我的:徽章,姓名,姓氏,年份和身份依次排列,彼此隔开一个空格。除了已经存在的库之外,我也无法添加其他库。
#include <stdio.h>
#include <string.h>
struct student {
int *badge;
char *name;
char *surname;
int *year;
char *status;
};
typedef struct student Student;
int main(){
}
【问题讨论】:
-
你有很多不需要是指针的指针。事实上,我认为结构中的所有指针应该不是指针,而是非指针值和数组。