c - 在 VS2017 中使用 fread_s 出现问题
问题描述
我试图从文本文件中读取一组数字。我正在使用 Visual Studio 2017 - 我在使用fread_s()
. 欢迎任何从文件中读取数字数组的方式。
#include "stdio.h"
#include "tchar.h"
#include "stdlib.h"
int main()
{
FILE *fp;
errno_t err_code;
int i_i;
int *arr_p;
int ch[10];
i_i = 0;
arr_p = &ch[0];
if ((err_code = fopen_s(&fp, "test.txt", "r")) != 0)
{
printf("File was not opened\n");
}
else
{
printf("%d :: %d ::%d \n", *arr_p, sizeof(ch), sizeof(int));
// This line of code, should ideally read the first number in the file
fread_s(arr_p, sizeof(ch), sizeof(int), 1, fp);
fclose(fp);
}
}
解决方案
推荐阅读
- flutter - Flutter如何重构小部件列表
- sql - SQL 错误 [42601]:错误:“0”处或附近的语法错误
- crm - 如何解决 Vtiger 错误:更改配置文件权限时出现“重复配置文件”
- go - 使用 big.Int int 编写帕斯卡三角形
- javascript - 显示为未定义的参数 - 导出的函数 JavaScript
- asp.net - 如何使用 asp.net 下载多个 zip 文件
- python - Python:使用 For 循环为未确定的嵌套级别创建 XML 嵌套标签字典
- python - 将列表转换为数组后创建列
- matlab - 创建显示大量 2D 随机游走在三个不同时间点的空间分布的图表
- android - 在 API 21 的 android API 级别 24 中投射 onALarmlistener 的替代方法是什么