由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Computation版 - 请问C语言fscanf的用法
相关主题
继续我们计算non-prime number 的探险a question about Matlab fread
choose three items of various weights to will fit into a knapsack of capacity 5如何用fprintf 连续写数据
问个C++读入文件的问题matlab输出问题
c++, sort() 为啥显示 结果不对[合集] 请教一段matlab程序 (转载)
那位大侠帮帮我!matlab问题[合集] 在matlab 如何 将生成的文件写到指定的目录。
Re: How to save variables in file in MAT[合集] 举个例子:每天一题
matlab高手进来看看,谢谢[合集] Matlab输出的文件怎么读进fortran?
[转载] matlab里面移动指针pointer问题matlab环境下如何建一个空文件
相关话题的讨论汇总
话题: pfile话题: variable2话题: variable1话题: fscanf话题: fopen
进入Computation版参与讨论
1 (共1页)
d*******2
发帖数: 340
1
FILE *pFile;
pFile=fopen("myfile.txt","r");
fscanf(pFile,"%e, %e, %e, %e",&variable1,&variable2,&variable3,&variable4)
fclose(pFile);
myfile.txt
4.232e-002, 4.232e-002, 4.232e-002, 4.232e-002
为什么不对呢?
先谢了!
l*****d
发帖数: 754
2
What's the error msg?

【在 d*******2 的大作中提到】
: FILE *pFile;
: pFile=fopen("myfile.txt","r");
: fscanf(pFile,"%e, %e, %e, %e",&variable1,&variable2,&variable3,&variable4)
: fclose(pFile);
: myfile.txt
: 4.232e-002, 4.232e-002, 4.232e-002, 4.232e-002
: 为什么不对呢?
: 先谢了!

d*******2
发帖数: 340
3
没有error message. 用
cout << "variable1: " << variable1 << endl;
cout << "variable2: " << variable2 << endl;
看,
variable1: 1
variable2: 7.7433e+268
variable1,variable2是double型. (double variable1,variable2;)

【在 l*****d 的大作中提到】
: What's the error msg?
l*****d
发帖数: 754
4
Google fopen C++, and see the parameter list of fopen function.

【在 d*******2 的大作中提到】
: 没有error message. 用
: cout << "variable1: " << variable1 << endl;
: cout << "variable2: " << variable2 << endl;
: 看,
: variable1: 1
: variable2: 7.7433e+268
: variable1,variable2是double型. (double variable1,variable2;)

d*******2
发帖数: 340
5
多谢,google了
http://www.cplusplus.com/reference/clibrary/cstdio/fopen.html
http://www.cplusplus.com/reference/clibrary/cstdio/fscanf.html
好象没错啊.能说详细一点吗?我智商偏低啊.

【在 l*****d 的大作中提到】
: Google fopen C++, and see the parameter list of fopen function.
l*****d
发帖数: 754
6
En, you changed your original post, but that is ok.
Please post the whole source code of the smallest complete program as you
found problem.

【在 d*******2 的大作中提到】
: 多谢,google了
: http://www.cplusplus.com/reference/clibrary/cstdio/fopen.html
: http://www.cplusplus.com/reference/clibrary/cstdio/fscanf.html
: 好象没错啊.能说详细一点吗?我智商偏低啊.

d***y
发帖数: 65
7
maybe you can try to use "%lf" instead of "%e"

【在 d*******2 的大作中提到】
: FILE *pFile;
: pFile=fopen("myfile.txt","r");
: fscanf(pFile,"%e, %e, %e, %e",&variable1,&variable2,&variable3,&variable4)
: fclose(pFile);
: myfile.txt
: 4.232e-002, 4.232e-002, 4.232e-002, 4.232e-002
: 为什么不对呢?
: 先谢了!

d*******2
发帖数: 340
8
正确答案! 多谢!

【在 d***y 的大作中提到】
: maybe you can try to use "%lf" instead of "%e"
1 (共1页)
进入Computation版参与讨论
相关主题
matlab环境下如何建一个空文件那位大侠帮帮我!matlab问题
请教一个C++程序结构的问题Re: How to save variables in file in MAT
matlab 做不规则 数据输入,求教matlab高手进来看看,谢谢
Matlab 读取文件的问题[转载] matlab里面移动指针pointer问题
继续我们计算non-prime number 的探险a question about Matlab fread
choose three items of various weights to will fit into a knapsack of capacity 5如何用fprintf 连续写数据
问个C++读入文件的问题matlab输出问题
c++, sort() 为啥显示 结果不对[合集] 请教一段matlab程序 (转载)
相关话题的讨论汇总
话题: pfile话题: variable2话题: variable1话题: fscanf话题: fopen