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 | | 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"
|
|