c - C中二进制文件的动态存储
问题描述
Participant *readRankingList (const char *filename, int *length) {
length = 0;
int i=0;
FILE *fp;
fp = fopen(filename, "rb");
Participant *list;
if (fp == NULL) {
fprintf(stderr, "*** open of %s failed ***\n", filename);
return 0;
}
length = fread((void *)list, sizeof(Participant), LIST_LEN, fp);
while(fread(list, sizeof(length), 1, fp)>0){
list[i]=list;
i++;
}
free(list);
fclose(fp);
*length = i;
return list;
}
我有一个二进制文件,我在这部分打开它。现在我想用动态存储来存储它。目前我得到一个
Warning : assignment makes pointer from intefer without a cast
和
Error: incompatible types when assigning to type Participant from type struct Participant
解决方案
推荐阅读
- java - Mockito UnfinishedVerificationException
- javascript - 如何测试酶的内部功能?
- css - 当使用 bootstrap4 更改页面大小时,使图像成为页面的中心?
- gradle - 在 init.gradle 脚本中应用插件配置
- wordpress - 图片来源未知 wordpress
- javascript - 在下拉项的锚标记中使用输入类型文件
- python - 为什么我们不能从文件对话框加载大尺寸文件并在 qml 中的 textArea 上显示文件数据?
- android - 操作系统关闭应用程序时识别释放的对象
- javascript - 在 raiseevent() 方法中存储 HTML 对象(div 元素) - Pepper robo
- r - 从日期列中获取天数