的fscanf [英] fscanf
问题描述
我做错了,我所知道的就是转向clc。我有一个
文本文件,其中包含由标签分隔的2个双打。
..26 0
是文本。我想阅读两个double并将它们打印出来。这是我的
档。
#include< stdio.h>
int main( ){
FILE * fp;
double x,y;
fp = fopen(" zo"," r"); / *错误检查简洁* /
fscanf(fp,"%。2f \t%。2f",& string);
fclose(fp );
printf("%。2f%.2f",x,y);
}
所有我get是包含在x和y中的垃圾。对于任何简单的
理由,我显然无法阅读并打印出来自
这个文本文件的stdin。我不认为恐惧是非常必要的。
比尔
I''m doing something wrong and all I know to do is turn to clc. I have a
text file containing 2 doubles separated by a tab.
..26 0
Is the text. I want to read the two double and printf them out. Here''s my
file.
#include <stdio.h>
int main() {
FILE *fp;
double x,y;
fp=fopen("zo","r"); /*error checking out for brevity */
fscanf(fp,"%.2f\t%.2f",&string);
fclose(fp);
printf("%.2f%.2f",x,y);
}
All I get is garbage that is contained in x and y. For whatever simple
reason that is beyond me evidently I can''t read and printf out to stdin from
this text file. I don''t think fread is really necessary.
Bill
推荐答案
8月18日,2 :上午39点,比尔坎宁安 < nos ... @ nspam.comwrote:
On Aug 18, 2:39 am, "Bill Cunningham" <nos...@nspam.comwrote:
我做错了什么,我所知道的就是转向clc。我有一个
文本文件,其中包含由标签分隔的2个双打。
.26 0
是文本。我想阅读两个double并将它们打印出来。这是我的
档。
#include< stdio.h>
int main( ){
FILE * fp;
double x,y;
fp = fopen(" zo"," r"); / *错误检查简洁* /
fscanf(fp,"%。2f \t%。2f",& string);
fclose(fp );
printf("%。2f%.2f",x,y);
}
我得到的只是包含在x和y中的垃圾。对于任何简单的
理由,我显然无法阅读并打印出来自
这个文本文件的stdin。我不认为恐惧是非常必要的。
I''m doing something wrong and all I know to do is turn to clc. I have a
text file containing 2 doubles separated by a tab.
.26 0
Is the text. I want to read the two double and printf them out. Here''s my
file.
#include <stdio.h>
int main() {
FILE *fp;
double x,y;
fp=fopen("zo","r"); /*error checking out for brevity */
fscanf(fp,"%.2f\t%.2f",&string);
fclose(fp);
printf("%.2f%.2f",x,y);
}
All I get is garbage that is contained in x and y. For whatever simple
reason that is beyond me evidently I can''t read and printf out to stdin from
this text file. I don''t think fread is really necessary.
你是个骗子,比尔。该代码无法编译,因此您无法获得执行此程序的任何内容。
You''re a liar, Bill. That code does not compile, so it''s impossible
for you to get anything out of executing this program.
On Sun,17 2008年8月23:39:25 +0000,比尔坎宁安 < no **** @ nspam.com>
写道:
On Sun, 17 Aug 2008 23:39:25 +0000, "Bill Cunningham" <no****@nspam.com>
wrote:
我做错了什么我知道的全部做转向clc。我有一个
文本文件,其中包含由标签分隔的2个双打。
.26 0
是文本。我想阅读两个double并将它们打印出来。这是我的文件
。
I''m doing something wrong and all I know to do is turn to clc. I have a
text file containing 2 doubles separated by a tab.
.26 0
Is the text. I want to read the two double and printf them out. Here''s
my file.
< snipped code>
请发布用于编译和生成导致垃圾打印的
可执行文件的* actual *代码。您发布的代码将无法编译。
- Anand
<snipped code>
Please post the *actual* code that you used to compile and generate the
executable that caused garbage to be printed. The code you posted will
not compile.
- Anand
" Anand Hariharan" < zn ******************** @ tznvy.pbzwrote in message
news:g8 ********** @ aioe.org ...
"Anand Hariharan" <zn********************@tznvy.pbzwrote in message
news:g8**********@aioe.org...
请发布用于编译的* actual *代码并生成导致垃圾的
可执行文件打印。您发布的代码将无法编译。
Please post the *actual* code that you used to compile and generate the
executable that caused garbage to be printed. The code you posted will
not compile.
好的,我确实写了这个。我将再次查看实际代码。
Bill
Ok I did write this on the fly. I will look again at the actual code.
Bill
这篇关于的fscanf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!