如何用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/12/23 02:16:53
如何用C的fread函数读取如下文件数据?(数据间有空格怎么处理?)1\x055.1\x053.5\x051.4\x050.2\x0512\x054.9\x053\x051.4\x050.2\x051

如何用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]);