为什么在Windows下没有定义stdprn? [英] Why is stdprn not defined under Windows?

查看:117
本文介绍了为什么在Windows下没有定义stdprn?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试打印到打印机。我在

Win 2K上使用VC ++ 6.0编译器,但是我收到错误,说明没有定义stdprn。为什么

呢?是因为Windows,我猜?我是否只需使用GDI32函数在Windows下进行打印?我可以不使用Windows下的

stdprn从内存打印到窗口吗?

解决方案

Sathyaish写道:

我正在尝试打印到打印机。我在Win 2K上使用VC ++ 6.0编译器,但是我得到一个错误,说明没有定义stdprn。


在C中没有名为''stdprn''的预定义流。你或许可以通过打开一个流来做你想要的
您的平台使用的名称

用于打印机。那可能是prn。例如,这适用于我的

Windows框:


#include< stdio.h>

#include< stdlib.h>


int main(无效)

{

FILE * prn;

if(!(prn = fopen(" prn"," wb")))} {

perror(无法打开\,输出和输出);

退出(EXIT_FAILURE);

}

fprintf(prn,这是一个简单的test.\ n);

fclose(prn);

返回0;

}

为什么



因为*没有在C中定义stdprn *这样的东西。

是因为Windows,我猜?




如果是这样,Windows做对了。


Sathyaish写道:

我试图打印到打印机。我在Win 2K上使用VC ++ 6.0编译器,但是我得到一个错误,说明没有定义stdprn。
为什么?是因为Windows,我猜?我是否必须仅使用GDI32功能在Windows下打印?我可以不使用Windows下的
stdprn从内存打印到窗口吗?




因为它不是C语言的一部分,为什么你问这个问题吗?


- g

-

Artie Gold - 德克萨斯州奥斯汀


如果你认为不重要,你就不会注意了。


>我正在尝试打印到打印机。


在标准C中没有标准的方法可以做到这一点,除非stdout连接到打印机。

。 br />

我在Win 2K上使用VC ++ 6.0编译器,但是我收到错误,说明没有定义stdprn。为什么


标准C中没有stdprn。

是什么?是因为Windows,我猜?我是否必须只使用


标准C中没有stdprn,无论平台如何。

" stdprn"是为程序员保留的名称。标题文件

喜欢< stdio.h>不应该定义它。

GDI32在Windows下打印的功能?我可以不使用Windows下的
stdprn从内存打印到窗口吗?




下定决心:打印到打印机还是打印机?窗口?

或者你的打印机本身有窗户吗?还要记住那里

并不保证计算机有打印机。或者它只有一台打印机只需要



许多想要打印的应用程序将它放在一个文件中然后

然后或者使用system()和特定于平台的命令打印

它,或者在程序结束后让别的东西做。


一些应用程序打开特定于系统的设备(例如PRN:或

" / dev / lpt0")并直接输出到它,就像它是一个文件一样。

无法保证应用程序可以与现场打印机打交道,而不是通过假脱机程序。


Gordon L. Burditt


I am trying to print to the printer. I am using a VC++ 6.0 compiler on
Win 2K, but I get an error saying that stdprn is not defined. Why is
that? Is it because of Windows, I am guessing? Do I have to use only
the GDI32 functions for printing under Windows? Can I not use the
stdprn under Windows to print from memory to the window?

解决方案

Sathyaish wrote:

I am trying to print to the printer. I am using a VC++ 6.0 compiler on
Win 2K, but I get an error saying that stdprn is not defined.
There is no pre-defined stream named ''stdprn'' in C. You might be able
to do what you want by opening a stream with the name your platform uses
for the printer. That might be "prn". For example, this works on my
Windows box:

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
FILE *prn;
if (!(prn = fopen("prn", "wb"))) {
perror("Could not open \"prn\" for output");
exit(EXIT_FAILURE);
}
fprintf(prn, "This is a simple test.\n");
fclose(prn);
return 0;
}
Why is
that?
Because there *is no such thing as stdprn* defined in C.
Is it because of Windows, I am guessing?



If so, Windows got something right.


Sathyaish wrote:

I am trying to print to the printer. I am using a VC++ 6.0 compiler on
Win 2K, but I get an error saying that stdprn is not defined. Why is
that? Is it because of Windows, I am guessing? Do I have to use only
the GDI32 functions for printing under Windows? Can I not use the
stdprn under Windows to print from memory to the window?



As it''s not a part of the C language, why are you asking here?

--ag

--
Artie Gold -- Austin, Texas

"If you don''t think it matters, you''re not paying attention."


>I am trying to print to the printer.

There is no standard way to do that in standard C, unless stdout is
connected to the printer.

I am using a VC++ 6.0 compiler on
Win 2K, but I get an error saying that stdprn is not defined. Why is
There is no stdprn in standard C.
that? Is it because of Windows, I am guessing? Do I have to use only
There is no stdprn in standard C, regardless of platform.
"stdprn" is a name reserved for the programmer. Header files
like <stdio.h> should not define it.
the GDI32 functions for printing under Windows? Can I not use the
stdprn under Windows to print from memory to the window?



Make up your mind: are you printing to a printer or to a window?
Or does your printer itself have windows? Also remember that there
is no guarantee that a computer has a printer. Or that it has only
one printer.

Many applications that want to print something put it in a file and
then either use system() with a platform-specific command to print
it, or let something else do it after the program has finished.

Some applications open a system-specific device (e.g. "PRN:" or
"/dev/lpt0") and output directly to it as though it were a file.
There is no guarantee that an application gets to talk to a "live"
printer rather than going through a spooler.

Gordon L. Burditt


这篇关于为什么在Windows下没有定义stdprn?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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