aha苔 发表于 2021-1-24 16:24:41

如何将数组结构体的数据保存至文件中并能从文件中读取数据

就是假设我定义了
struct student
{
        char stunum;
        char name;
        int age;
        char sex;
        int byear;
        int bmonth;
        int bday;
        char place;
        char phnum;
        char email;
}stu;
这样一个结构体,在输入数据后保存至文件中,如何又从文件中读取我的数据并保存至数组中呢?

一世轻尘 发表于 2021-1-24 17:53:54

本帖最后由 一世轻尘 于 2021-1-24 17:55 编辑

利用fread,fscanf函数
可参考fread -- 从文件中读取数据
https://fishc.com.cn/thread-91252-1-1.html
(出处: 鱼C论坛)
fscanf -- 从文件中读取格式化输入
https://fishc.com.cn/thread-91246-1-1.html
(出处: 鱼C论坛)

dysow 发表于 2021-1-25 11:42:07

用fread,fwrite保存块数据就可以,最近我也在研究,总算明白点了
页: [1]
查看完整版本: 如何将数组结构体的数据保存至文件中并能从文件中读取数据