我正在使用 VC++ 2008 Express Edition for C。当我尝试运行此命令时:
/* Demonstrates printer output. */
#include <stdio.h>
main()
{
float f = 2.0134;
fprintf(stdprn, "This message is printed.\n\n");
fprintf(stdprn, "And now some numbers:\n\n");
fprintf(stdprn, "The square of %f is %f.", f, f*f);
/* Send a form feed */
fprintf(stdprn, "\f");
}
我收到以下四个错误: error C2065: 'stdprn' : 未声明的标识符。
On this http://www.codeguru.com/forum/archive/index.php/t-285513.html论坛上,他们写道,可以按如下方式定义打印机:
FILE *printer;
printer = fopen("PRN", "w");
EDIT它构建时会警告 fopen 不安全。运行时出现错误:
调试断言失败。
文件:f:\dd\vctools\crt_bld\self_x86\crt\src\fprintf.c
线路:55
表达式:(str != NULL)
The stdprn
Stream 是 Borland 编译器提供的扩展 - 据我所知,MS 从未支持过它。关于使用fopen
要打开打印机设备,我认为这不适用于任何最新版本的 Windows,但可以尝试以下几点:
- use
PRN:
作为名称而不是PRN
(注意冒号)
- 尝试使用(例如)打开特定设备
LPT1:
(再次注意冒号)。如果您没有连接打印机,这当然不起作用。
- 不要依赖于出现的打印机对话框 - 当您采用这种方法时,您并没有真正使用 WIndows 打印系统(因此它可能无法解决您的问题,但值得一试)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)