我需要帮助将文本文件转换为 C 的二进制文件。即使我已经写了一半,我也无法继续执行我的程序,因为我不知道是否正在打印任何值。转换需要人或动物的最大值、宽度、长度和字符串。基本上我正在编写的程序读取二进制数据库文件并返回所有满足搜索的值。谢谢您的帮助
#include <stdio.h>
#include <string.h>
typedef struct{
int max;
double length, width;
char people;
} max_t;
int
main()
{
FILE *database;
int inp, out;
database = fopen("database.txt", "r");
fscanf(database, "Max : %d", &max);
fscanf(database, "Width : %lf", &width);
fscanf(database, "Length : %lf", &length);
fscanf(database, "People : %s", &people);
fwrite(&max, 1, sizeof(max), database);
fwrite(&width, 1, sizeof(width), database);
fwrite(&length, 1, sizeof(length), database);
fwrite(&people, 1, sizeof(people), database);
database = fopen("out.txt", "wb");
return(0);
}