如何用C的fread函数读取如下文件数据?(数据间有空格怎么处理?)1\x055.1\x053.5\x051.4\x050.2\x0512\x054.9\x053\x051.4\x050.2\x0513\x054.7\x053.2\x051.3\x050.2\x0514\x054.6\x053.1\x051.5\x050.2\x0515\x055\x053.6\x051.4\x050.2\x0
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/23 17:21:02
![如何用C的fread函数读取如下文件数据?(数据间有空格怎么处理?)1\x055.1\x053.5\x051.4\x050.2\x0512\x054.9\x053\x051.4\x050.2\x0513\x054.7\x053.2\x051.3\x050.2\x0514\x054.6\x053.1\x051.5\x050.2\x0515\x055\x053.6\x051.4\x050.2\x0](/uploads/image/z/14184436-4-6.jpg?t=%E5%A6%82%E4%BD%95%E7%94%A8C%E7%9A%84fread%E5%87%BD%E6%95%B0%E8%AF%BB%E5%8F%96%E5%A6%82%E4%B8%8B%E6%96%87%E4%BB%B6%E6%95%B0%E6%8D%AE%3F%EF%BC%88%E6%95%B0%E6%8D%AE%E9%97%B4%E6%9C%89%E7%A9%BA%E6%A0%BC%E6%80%8E%E4%B9%88%E5%A4%84%E7%90%86%3F%EF%BC%891%5Cx055.1%5Cx053.5%5Cx051.4%5Cx050.2%5Cx0512%5Cx054.9%5Cx053%5Cx051.4%5Cx050.2%5Cx0513%5Cx054.7%5Cx053.2%5Cx051.3%5Cx050.2%5Cx0514%5Cx054.6%5Cx053.1%5Cx051.5%5Cx050.2%5Cx0515%5Cx055%5Cx053.6%5Cx051.4%5Cx050.2%5Cx0)
如何用C的fread函数读取如下文件数据?(数据间有空格怎么处理?)1\x055.1\x053.5\x051.4\x050.2\x0512\x054.9\x053\x051.4\x050.2\x0513\x054.7\x053.2\x051.3\x050.2\x0514\x054.6\x053.1\x051.5\x050.2\x0515\x055\x053.6\x051.4\x050.2\x0
如何用C的fread函数读取如下文件数据?(数据间有空格怎么处理?)
1\x055.1\x053.5\x051.4\x050.2\x051
2\x054.9\x053\x051.4\x050.2\x051
3\x054.7\x053.2\x051.3\x050.2\x051
4\x054.6\x053.1\x051.5\x050.2\x051
5\x055\x053.6\x051.4\x050.2\x051
6\x055.4\x053.9\x051.7\x050.4\x051
7\x054.6\x053.4\x051.4\x050.3\x051
8\x055\x053.4\x051.5\x050.2\x051
9\x054.4\x052.9\x051.4\x050.2\x051
10\x054.9\x053.1\x051.5\x050.1\x051
11\x055.4\x053.7\x051.5\x050.2\x051
12\x054.8\x053.4\x051.6\x050.2\x051
13\x054.8\x053\x051.4\x050.1\x051
14\x054.3\x053\x051.1\x050.1\x051
15\x055.8\x054\x051.2\x050.2\x051
16\x055.7\x054.4\x051.5\x050.4\x051
17\x055.4\x053.9\x051.3\x050.4\x051
18\x055.1\x053.5\x051.4\x050.3\x051
19\x055.7\x053.8\x051.7\x050.3\x051
20\x055.1\x053.8\x051.5\x050.3\x051
定义的结构体形式为
struct IRIS
{
\x05int Serial_number;
double parameter[4];
\x05int type;
}sample[30];
利用C语言的fread函数读取文件中每行数据到结构体数组中…………
如何用C的fread函数读取如下文件数据?(数据间有空格怎么处理?)1\x055.1\x053.5\x051.4\x050.2\x0512\x054.9\x053\x051.4\x050.2\x0513\x054.7\x053.2\x051.3\x050.2\x0514\x054.6\x053.1\x051.5\x050.2\x0515\x055\x053.6\x051.4\x050.2\x0
用fread不方便,fscanf快
直接循环
fscanf(fp,"%d %lf %lf %lf %lf",
&sample[i].Serial_number,
&sample[i].parameter[0],
&sample[i].parameter[1],
&sample[i].parameter[2],
&sample[i].parameter[3]);