我怎样才能使MS VC ++防爆preSS版在C打印机的工作? [英] How can I make the printer work in C in MS VC++ Express edition?
问题描述
我使用VC ++ 2008的前preSS为C.版当我尝试运行此:
I am using VC++ 2008 express edition for C. When I try to run this:
/* 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");
}
我得到这些错误四:错误C2065:STDPRN':未声明的标识符
I get four of these errors: error C2065: 'stdprn' : undeclared identifier.
在此论坛,他们写道,它的工作原理来定义打印机如下:
On this forum, they wrote that it works to define the printer as follows:
FILE *printer;
printer = fopen("PRN", "w");
修改
它建立与FOPEN是不安全的警告。当它运行时出现错误:
EDIT It builds with a warning that fopen is unsafe. When it runs the error appears:
调试断言失败。
文件:F:\\ DD \\ vctools \\ crt_bld \\ self_x86 \\ CRT \\ SRC \\ fprintf.c
行:55
Debug Assertion fails. File: f:\dd\vctools\crt_bld\self_x86\crt\src\fprintf.c Line: 55
防爆pression:(!STR = NULL)
Expression: (str != NULL)
推荐答案
的 STDPRN
流是由Borland编译器提供的扩展 - 因为据我所知,微软从来没有支持它。关于FOPEN 使用的打开打印机设备,我不认为这将与最近的任何版本的Windows上运行,但有几样事情尝试:
The stdprn
stream was an extension provided by Borland compilers - as far as I know, MS have never supported it. Regarding the use of fopen
to open the printer device, I don't think this will work with any recent versions of Windows, but a couple of things to try:
- 使用
PRN:
作为名称,而不是PRN
(注意冒号) - 尝试打开使用(例如)特定设备
LPT1:
(再次,注意冒号)。这当然,如果你没有一台打印机连接不起作用。 - 请不要依赖于打印对话框来了 - 你是不是真的使用Windows打印系统,当你采取这种方式(所以它可能不会解决你的问题,但值得一试)李。 >
- use
PRN:
as the name instead ofPRN
(note the colon) - try opening the specific device using (for example)
LPT1:
(once again, note the colon). This will of course not work if you don't have a printer attached. - don't depend on a printer dialog coming up - you are not really using the WIndows printing system when you take this approach (and so it probably won't solve your problem, but is worth a try).
这篇关于我怎样才能使MS VC ++防爆preSS版在C打印机的工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!