Why is stdprn not defined under Windows?

Discussion in 'C Programming' started by Sathyaish, Oct 6, 2004.

  1. Sathyaish

    Sathyaish Guest

    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, Oct 6, 2004
    #1
    1. Advertising

  2. Off Topic: Why is stdprn not defined under Windows?

    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?


    I don't do Windows so I can't answer any of your questions about them.
    Try one of the many Windows specific newsgroups.

    In UNIX, a printer is just another file
    that you can open for writing if you have the correct permissions.
    Unlike terminals, printers are usually shared.
    This can cause problems if two or more applications
    are trying to write to the same printer at the same time
    so you may need some kind of monitor to mange requests
    and queues for print jobs.
     
    E. Robert Tisdale, Oct 6, 2004
    #2
    1. Advertising

  3. 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.
     
    Martin Ambuhl, Oct 6, 2004
    #3
  4. Sathyaish

    Artie Gold Guest

    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."
     
    Artie Gold, Oct 6, 2004
    #4
  5. >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
     
    Gordon Burditt, Oct 6, 2004
    #5
  6. On 5 Oct 2004 17:41:29 -0700, in comp.lang.c ,
    (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?


    Because there's no such thing as a printer. Seriously.

    >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?


    The ability to print is totally system specific, and you should reasonably
    expect to have to use system-specific functionality to do it. You'd need to
    ask in a Windows group for how to do that tho.

    --
    Mark McIntyre
    CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
    CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
     
    Mark McIntyre, Oct 6, 2004
    #6
  7. Sathyaish

    pete Guest

    Re: Off Topic: Why is stdprn not defined under Windows?

    E. Robert Tisdale wrote:

    > In UNIX, a printer is just another file


    In C, streams are associated with files.
    What your standard output stream goes to,
    and where your standard input stream comes from,
    are files.

    --
    pete
     
    pete, Oct 6, 2004
    #7
  8. Sathyaish

    Dan Pop Guest

    In <> (Sathyaish) writes:

    >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?


    It is the implementation's way to suggest that you should "talk" to the
    printer using the Windows printing services and not <stdio.h> streams.
    Take the hint.

    Dan
    --
    Dan Pop
    DESY Zeuthen, RZ group
    Email:
    Currently looking for a job in the European Union
     
    Dan Pop, Oct 6, 2004
    #8
  9. Sathyaish

    Ben Pfaff Guest

    Re: Off Topic: Why is stdprn not defined under Windows?

    pete <> writes:

    > E. Robert Tisdale wrote:
    >
    >> In UNIX, a printer is just another file

    >
    > In C, streams are associated with files.
    > What your standard output stream goes to,
    > and where your standard input stream comes from,
    > are files.


    Not all C streams are associated with files, as C99 7.19.2 points
    out:

    Input and output, whether to or from physical devices
    such as terminals and tape drives, or whether to or from
    files supported on structured storage devices, [...]
    --
    "In My Egotistical Opinion, most people's C programs should be indented six
    feet downward and covered with dirt." -- Blair P. Houghton
     
    Ben Pfaff, Oct 6, 2004
    #9
  10. Re: Off Topic: Why is stdprn not defined under Windows?

    On Wed, 06 Oct 2004 12:58:18 -0700, in comp.lang.c , Ben Pfaff
    <> wrote:

    >pete <> writes:
    >
    >> E. Robert Tisdale wrote:
    >>
    >>> In UNIX, a printer is just another file

    >>
    >> In C, streams are associated with files.
    >> What your standard output stream goes to,
    >> and where your standard input stream comes from,
    >> are files.

    >
    >Not all C streams are associated with files,


    sort-of depends how you choose to define "file".

    File (n): end point of a C stream.

    :)

    --
    Mark McIntyre
    CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
    CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>


    ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
     
    Mark McIntyre, Oct 6, 2004
    #10
  11. Sathyaish

    pete Guest

    Re: Off Topic: Why is stdprn not defined under Windows?

    Ben Pfaff wrote:
    >
    > pete <> writes:
    >
    > > E. Robert Tisdale wrote:
    > >
    > >> In UNIX, a printer is just another file

    > >
    > > In C, streams are associated with files.
    > > What your standard output stream goes to,
    > > and where your standard input stream comes from,
    > > are files.

    >
    > Not all C streams are associated with files,
    > as C99 7.19.2 points out:
    >
    > Input and output, whether to or from physical devices
    > such as terminals and tape drives, or whether to or from
    > files supported on structured storage devices, [...]


    I disagree.
    A physical device, such as a terminal, is an example of a file.

    N869
    7.19.3 Files
    [#1] A stream is associated with an external file (which may
    be a physical device) by opening a file, which may involve
    creating a new file. Creating an existing file causes its
    former contents to be discarded, if necessary. If a file
    can support positioning requests (such as a disk file, as
    opposed to a terminal), ...

    --
    pete
     
    pete, Oct 7, 2004
    #11
  12. Sathyaish

    Alan Balmer Guest

    Re: Off Topic: Why is stdprn not defined under Windows?

    On Thu, 07 Oct 2004 04:48:58 GMT, pete <> wrote:

    >Ben Pfaff wrote:
    >>
    >> pete <> writes:
    >>
    >> > E. Robert Tisdale wrote:
    >> >
    >> >> In UNIX, a printer is just another file
    >> >
    >> > In C, streams are associated with files.
    >> > What your standard output stream goes to,
    >> > and where your standard input stream comes from,
    >> > are files.

    >>
    >> Not all C streams are associated with files,
    >> as C99 7.19.2 points out:
    >>
    >> Input and output, whether to or from physical devices
    >> such as terminals and tape drives, or whether to or from
    >> files supported on structured storage devices, [...]

    >
    >I disagree.
    >A physical device, such as a terminal, is an example of a file.
    >
    >N869
    > 7.19.3 Files
    > [#1] A stream is associated with an external file (which may
    > be a physical device) by opening a file, which may involve
    > creating a new file. Creating an existing file causes its
    > former contents to be discarded, if necessary. If a file
    > can support positioning requests (such as a disk file, as
    > opposed to a terminal), ...


    That says a file *may be* a physical device. It does not say a
    physical device *is* a file.

    Some OS's, notably Unix, treat devices as files. Some don't.

    --
    Al Balmer
    Balmer Consulting
     
    Alan Balmer, Oct 7, 2004
    #12
  13. Sathyaish

    Dan Pop Guest

    Re: Off Topic: Why is stdprn not defined under Windows?

    In <> pete <> writes:

    >Ben Pfaff wrote:
    >>
    >> pete <> writes:
    >>
    >> > E. Robert Tisdale wrote:
    >> >
    >> >> In UNIX, a printer is just another file
    >> >
    >> > In C, streams are associated with files.
    >> > What your standard output stream goes to,
    >> > and where your standard input stream comes from,
    >> > are files.

    >>
    >> Not all C streams are associated with files,
    >> as C99 7.19.2 points out:
    >>
    >> Input and output, whether to or from physical devices
    >> such as terminals and tape drives, or whether to or from
    >> files supported on structured storage devices, [...]

    >
    >I disagree.
    >A physical device, such as a terminal, is an example of a file.


    Be careful when dealing with semantics issues. A physical device and a
    file are two completely different things. A file is something else
    than the physical storage device on which it resides.

    Even if the OS provides a file-like interface to a physical device, the
    physical device is still not a file. A terminal is a lot more than the
    one, two or three streams that may be connected to it at program startup.

    Dan
    --
    Dan Pop
    DESY Zeuthen, RZ group
    Email:
    Currently looking for a job in the European Union
     
    Dan Pop, Oct 7, 2004
    #13
  14. Sathyaish

    pete Guest

    Re: Off Topic: Why is stdprn not defined under Windows?

    Dan Pop wrote:
    >
    > In <> pete <> writes:
    >
    > >Ben Pfaff wrote:
    > >>
    > >> pete <> writes:
    > >>
    > >> > E. Robert Tisdale wrote:
    > >> >
    > >> >> In UNIX, a printer is just another file
    > >> >
    > >> > In C, streams are associated with files.
    > >> > What your standard output stream goes to,
    > >> > and where your standard input stream comes from,
    > >> > are files.
    > >>
    > >> Not all C streams are associated with files,
    > >> as C99 7.19.2 points out:
    > >>
    > >> Input and output, whether to or from physical devices
    > >> such as terminals and tape drives, or whether to or from
    > >> files supported on structured storage devices, [...]

    > >
    > >I disagree.
    > >A physical device, such as a terminal, is an example of a file.

    >
    > Be careful when dealing with semantics issues.
    > A physical device and a
    > file are two completely different things. A file is something else
    > than the physical storage device on which it resides.
    >
    > Even if the OS provides a file-like interface to a physical device,
    > the physical device is still not a file.
    > A terminal is a lot more than the one,
    > two or three streams that may be connected to it at program startup.


    I'm under the impression, that when standard output
    shows up on my PanaSync S70 monitor and that when I enter
    standard input on my Lexmark model M keyboard,
    that those two devices are files.
    They are files, aren't they?

    --
    pete
     
    pete, Oct 8, 2004
    #14
  15. Sathyaish

    Mike Wahler Guest

    Re: Off Topic: Why is stdprn not defined under Windows?

    "pete" <> wrote in message
    news:...
    >
    > I'm under the impression, that when standard output
    > shows up on my PanaSync S70 monitor and that when I enter
    > standard input on my Lexmark model M keyboard,
    > that those two devices are files.
    > They are files, aren't they?


    I wouldn't say so. I'd say they are devices (to which
    standard streams are attached).

    -Mike
     
    Mike Wahler, Oct 8, 2004
    #15
  16. Sathyaish

    Dan Pop Guest

    Re: Off Topic: Why is stdprn not defined under Windows?

    In <> pete <> writes:

    >Dan Pop wrote:
    >>
    >> In <> pete <> writes:
    >>
    >> >Ben Pfaff wrote:
    >> >>
    >> >> pete <> writes:
    >> >>
    >> >> > E. Robert Tisdale wrote:
    >> >> >
    >> >> >> In UNIX, a printer is just another file
    >> >> >
    >> >> > In C, streams are associated with files.
    >> >> > What your standard output stream goes to,
    >> >> > and where your standard input stream comes from,
    >> >> > are files.
    >> >>
    >> >> Not all C streams are associated with files,
    >> >> as C99 7.19.2 points out:
    >> >>
    >> >> Input and output, whether to or from physical devices
    >> >> such as terminals and tape drives, or whether to or from
    >> >> files supported on structured storage devices, [...]
    >> >
    >> >I disagree.
    >> >A physical device, such as a terminal, is an example of a file.

    >>
    >> Be careful when dealing with semantics issues.
    >> A physical device and a
    >> file are two completely different things. A file is something else
    >> than the physical storage device on which it resides.
    >>
    >> Even if the OS provides a file-like interface to a physical device,
    >> the physical device is still not a file.
    >> A terminal is a lot more than the one,
    >> two or three streams that may be connected to it at program startup.

    >
    >I'm under the impression, that when standard output
    >shows up on my PanaSync S70 monitor and that when I enter
    >standard input on my Lexmark model M keyboard,
    >that those two devices are files.
    >They are files, aren't they?


    The answer is available in the included text from the standard that is
    still visible above: they are physical devices. If they were files,
    you could destroy the output you have generated on your monitor with
    a remove() function call and reread the user input as many times as you
    wanted by closing and reopening the keyboard.

    Why do you think the standard *explicitly* talks about two categories of
    sources/destinations for I/O operations: physical devices and files
    supported on *structured storage devices*?

    Dan
    --
    Dan Pop
    DESY Zeuthen, RZ group
    Email:
    Currently looking for a job in the European Union
     
    Dan Pop, Oct 8, 2004
    #16
  17. Re: Off Topic: Why is stdprn not defined under Windows?

    (Dan Pop) writes:
    [...]
    > The answer is available in the included text from the standard that is
    > still visible above: they are physical devices. If they were files,
    > you could destroy the output you have generated on your monitor with
    > a remove() function call and reread the user input as many times as you
    > wanted by closing and reopening the keyboard.
    >
    > Why do you think the standard *explicitly* talks about two categories of
    > sources/destinations for I/O operations: physical devices and files
    > supported on *structured storage devices*?


    Whether a device is considered a file is a question about the meaning
    of the word "file". The standard doesn't provide an explicit
    definition, but it does have wording that clearly implies that a
    device can be a file.

    In the following, I'll use underscores to denote italics.

    C99 7.19.2 p1 says:

    Input and output, whether to or from physical devices such as
    terminals and tape drives, or whether to or from files supported
    on structured storage devices, are mapped into logical data
    _streams_, whose properties are more uniform than their various
    inputs and outputs.

    This makes a clear distinction between physical devices and files on
    structured storage devices, but it doesn't quite state that physical
    devices are not files. The ambiguity is in the interpretation of the
    phrase "files supported on structured storage devices"; does it imply
    that *all* files are "supported on structured storage devices", or is
    it merely talking about the subset of files that are "supported on
    structured storage devices"? Since it doesn't refer to physical
    devices as files, it's difficult to tell from this passage alone.

    But C99 7.19.3 p1 says:

    A stream is associated with an external file (which may be a
    physical device) by _opening_ a file, which may involve _creating_
    a new file.

    That seems pretty clear to me.

    Presumably a remove() operation on an external file that is a physical
    device would fail (though it could conceivably unplug the device from
    the system if the implementer is sufficiently perverse). Similarly,
    there's no reason to expect that closing and re-opening a physical
    device will let you re-read the same input. You can't even assume
    that for a disk file, since some external entity (such as another
    process) might have modified the file in the meantime.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
     
    Keith Thompson, Oct 8, 2004
    #17
  18. Sathyaish

    pete Guest

    Re: Off Topic: Why is stdprn not defined under Windows?

    Dan Pop wrote:
    >
    > In <> pete <> writes:
    >
    > >Dan Pop wrote:
    > >>
    > >> In <> pete <> writes:
    > >>
    > >> >Ben Pfaff wrote:
    > >> >>
    > >> >> pete <> writes:
    > >> >>
    > >> >> > E. Robert Tisdale wrote:
    > >> >> >
    > >> >> >> In UNIX, a printer is just another file
    > >> >> >
    > >> >> > In C, streams are associated with files.
    > >> >> > What your standard output stream goes to,
    > >> >> > and where your standard input stream comes from,
    > >> >> > are files.
    > >> >>
    > >> >> Not all C streams are associated with files,
    > >> >> as C99 7.19.2 points out:
    > >> >>
    > >> >> Input and output, whether to or from physical devices
    > >> >> such as terminals and tape drives, or whether to or from
    > >> >> files supported on structured storage devices, [...]
    > >> >
    > >> >I disagree.
    > >> >A physical device, such as a terminal, is an example of a file.
    > >>
    > >> Be careful when dealing with semantics issues.
    > >> A physical device and a
    > >> file are two completely different things. A file is something else
    > >> than the physical storage device on which it resides.
    > >>
    > >> Even if the OS provides a file-like interface to a physical device,
    > >> the physical device is still not a file.
    > >> A terminal is a lot more than the one,
    > >> two or three streams that may be connected to it at program startup.

    > >
    > >I'm under the impression, that when standard output
    > >shows up on my PanaSync S70 monitor and that when I enter
    > >standard input on my Lexmark model M keyboard,
    > >that those two devices are files.
    > >They are files, aren't they?

    >
    > The answer is available in the included text from the standard that is
    > still visible above: they are physical devices. If they were files,
    > you could destroy the output you have generated on your monitor with
    > a remove() function call and reread the user input as many times as you
    > wanted by closing and reopening the keyboard.
    >
    > Why do you think the standard *explicitly*
    > talks about two categories of sources/destinations
    > for I/O operations: physical devices and files
    > supported on *structured storage devices*?


    Because disk files are substantially different from files
    which are physical devices.
    What kind of physical device do you think the standard
    is refering to, when it says that a file may be a physical device?

    This sentence:
    N869
    7.19.3 Files
    [#1] If a file
    can support positioning requests (such as a disk file, as
    opposed to a terminal), then a file position indicator
    associated with the stream is positioned at the start
    (character number zero) of the file, unless the file is
    opened with append mode in which case it is implementation-
    defined whether the file position indicator is initially
    positioned at the beginning or the end of the file.

    doesn't make any sense, unless a disk file is one kind of file,
    and a terminal is another kind of file.

    --
    pete
     
    pete, Oct 9, 2004
    #18
  19. Sathyaish

    Mabden Guest

    Re: Off Topic: Why is stdprn not defined under Windows?

    "Keith Thompson" <> wrote in message
    news:...
    > Presumably a remove() operation on an external file that is a physical
    > device would fail (though it could conceivably unplug the device from
    > the system if the implementer is sufficiently perverse).


    I don't think that "unplugging the device" is necessarily "perverse". I
    have a USB device that reads memory cards. I can plug in my camera
    memory stick and copy files from it. When I want to remove the stick, I
    "unplug or eject" the media. If there is no memory stick in the device
    and I click "unplug or eject", it just shuts off the SmartDisk device
    (the LED goes off and the icon is removed from the taskbar).

    --
    Mabden
     
    Mabden, Oct 9, 2004
    #19
  20. Re: Off Topic: Why is stdprn not defined under Windows?

    "Mabden" <mabden@sbc_global.net> writes:
    > "Keith Thompson" <> wrote in message
    > news:...
    >> Presumably a remove() operation on an external file that is a physical
    >> device would fail (though it could conceivably unplug the device from
    >> the system if the implementer is sufficiently perverse).

    >
    > I don't think that "unplugging the device" is necessarily "perverse". I
    > have a USB device that reads memory cards. I can plug in my camera
    > memory stick and copy files from it. When I want to remove the stick, I
    > "unplug or eject" the media. If there is no memory stick in the device
    > and I click "unplug or eject", it just shuts off the SmartDisk device
    > (the LED goes off and the icon is removed from the taskbar).


    Sure, but the question is whether a call to remove() should do this.
    I would find such behavior odd, but it would be perfectly legal as far
    as the standard is concerned.

    <OT>On a Unix-like system, remove() would be more likely to delete the
    entry in /dev rather than doing anything to the physical device, but
    only if the caller has appropriate privileges.</OT>

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
     
    Keith Thompson, Oct 9, 2004
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bo Peng
    Replies:
    1
    Views:
    474
    Bo Peng
    Jan 9, 2006
  2. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    917
    Mark Rae
    Dec 21, 2006
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,030
    Smokey Grindel
    Dec 2, 2006
  4. Oodini
    Replies:
    1
    Views:
    1,784
    Keith Thompson
    Sep 27, 2005
  5. Replies:
    1
    Views:
    509
    Sion Arrowsmith
    Jul 10, 2008
Loading...

Share This Page