打印到文件问题 [英] print to file question

查看:66
本文介绍了打印到文件问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

愚蠢的问题,我知道,但我有一个代码片段,如下所示:


printf(" blah blah");

printf (更多等等);


x = a + b - c;

printf($%3.2f \ n",x);


y = d + e;

printf($%3.2f \ n,y);


printf (stuff);

而不是打印到DOS窗口(就像现在一样),我想要输出打印到文件的
以便然后,文件可以由收据打印机打印为

收据。并不是真的很重要,但是这一切都是在XP Pro上的。 -Phil

Silly question, I know, but I have a code snippet that looks like this:

printf("blah blah");
printf("more blah");

x = a + b - c;
printf($%3.2f\n", x);

y = d + e;
printf($%3.2f\n, y);

printf("stuff");
and instead of it printing to the DOS window (as it does now), I want
the output to print to a file so that the file may then be printed as a
receipt by a receipt printer. Not that it really matters, but this is
all on XP Pro. -Phil

推荐答案

%3.2f\ n",x);


y = d + e;

printf(
%3.2f\n", x);

y = d + e;
printf(


%3.2f \ n,y);


printf( stuff);

而不是它打印到DOS窗口(就像现在一样),我希望

输出打印到文件中,以便然后,文件可以由收据打印机打印为

收据。并不是真的很重要,但是这一切都是在XP Pro上的。 -Phil

%3.2f\n, y);

printf("stuff");
and instead of it printing to the DOS window (as it does now), I want
the output to print to a file so that the file may then be printed as a
receipt by a receipt printer. Not that it really matters, but this is
all on XP Pro. -Phil


而不是打印到DOS窗口(就像现在一样),我想要
and instead of it printing to the DOS window (as it does now), I want

要打印到文件的输出,以便文件可以打印为收据打印机的收据。
the output to print to a file so that the file may then be printed as
a receipt by a receipt printer.



使用DOS命令

程序文件名


或者如果你想解决它C,使用

FILE * f = fopen(" filename"," w");

if(f == NULL){ERROR ...}

fprintf(f," format string",arguments ...);

if(fclose(f)!= 0){ERROR ...; }


-

Hallvard

Use the DOS command
program filename

Or if you want to solve it in C, use
FILE *f = fopen("filename", "w");
if (f == NULL) { ERROR... }
fprintf(f, "format string", arguments...);
if (fclose(f) != 0) { ERROR...; }

--
Hallvard


这篇关于打印到文件问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆