printing from 'C' - Redhat

This is a discussion on printing from 'C' - Redhat ; In must versions of 'C' there is a stream to direct output to the printer: EG: stdprn printf(strprn, "Hello World"); // prints to the default printer How do I do this in Redhat ? There is no stream 'stdprn' though ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: printing from 'C'

  1. printing from 'C'

    In must versions of 'C' there is a stream to direct output to the
    printer: EG: stdprn

    printf(strprn, "Hello World"); // prints to the default printer

    How do I do this in Redhat ? There is no stream 'stdprn' though
    'stdout' and 'stderr' exist ok ?

    Please reply copy by email.

    Georges


  2. Re: printing from 'C'

    Georges wrote:
    > In must versions of 'C' there is a stream to direct output to the
    > printer: EG: stdprn
    >
    > printf(strprn, "Hello World"); // prints to the default printer
    >
    > How do I do this in Redhat ? There is no stream 'stdprn' though
    > 'stdout' and 'stderr' exist ok ?


    I have never heard of "strprn" in C and I have been writing in C since the
    early 1970s. If you really want to use strprn, you have three choices:

    1.) Add:

    int strprn;
    strprn = stdout;

    to your source code.

    2.) Add

    #define strprn stdout

    to your source code.

    3.) Add

    int strprn;
    strprn = open(....);
    if (strprn < 0) {
    handle error
    }

    to your source code.
    >
    > Please reply copy by email.
    >

    NO. This is a news group, not a mailing list. If you choose to post here,
    then _here_ is where you should expect your answers.

    > Georges
    >



    --
    .~. Jean-David Beyer Registered Linux User 85642.
    /V\ Registered Machine 241939.
    /( )\ Shrewsbury, New Jersey http://counter.li.org
    ^^-^^ 08:40:00 up 9 days, 21:36, 4 users, load average: 4.18, 4.17, 4.15


  3. Re: printing from 'C'

    Georges wrote:

    > In must versions of 'C' there is a stream to direct output to the
    > printer: EG: stdprn
    >
    > printf(strprn, "Hello World"); // prints to the default printer
    >
    > How do I do this in Redhat ? There is no stream 'stdprn' though
    > 'stdout' and 'stderr' exist ok ?
    >
    > Please reply copy by email.
    >
    > Georges

    Hello do you want to print with QT or normal from shell ?

    QT has good classes to print with c++

    I do it in my program to and it works nice ( greyscale and color printing )


    --
    Dirk Wendland
    working on : develop a tool for c++ | html | java | php
    develop.if2.de

  4. Re: printing from 'C'

    Georges writes:
    >In must versions of 'C' there is a stream to direct output to the
    >printer: EG: stdprn


    In over 25 years of writing C code, I've never seen such a thing
    as "stdprn". It is certainly not part of "must" versions of
    'C'. It is certainly not part of ANSI C or C99.

    >
    > printf(strprn, "Hello World"); // prints to the default printer
    >
    >How do I do this in Redhat ? There is no stream 'stdprn' though
    >'stdout' and 'stderr' exist ok ?


    Write to a file and use the 'lp' or 'lpr' commands to print it.
    Use the 'system(3)' library function, if necessary.

    If you really want to talk directly to the printer bypassing the
    spooler and any filtering and ppd processing, you can:

    FILE *stdprn = fopen("/dev/lp", "w");

    But, I don't recommend you do this.

    >
    >Please reply copy by email.


    No.

    scott


  5. Re: printing from 'C'

    scott@slp53.sl.home (Scott Lurndal) writes:

    > Georges writes:
    > >In must versions of 'C' there is a stream to direct output to the
    > >printer: EG: stdprn

    >
    > In over 25 years of writing C code, I've never seen such a thing
    > as "stdprn". It is certainly not part of "must" versions of
    > 'C'. It is certainly not part of ANSI C or C99.
    >
    > >
    > > printf(strprn, "Hello World"); // prints to the default printer
    > >
    > >How do I do this in Redhat ? There is no stream 'stdprn' though
    > >'stdout' and 'stderr' exist ok ?

    >
    > Write to a file and use the 'lp' or 'lpr' commands to print it.
    > Use the 'system(3)' library function, if necessary.
    >
    > If you really want to talk directly to the printer bypassing the
    > spooler and any filtering and ppd processing, you can:
    >
    > FILE *stdprn = fopen("/dev/lp", "w");
    >
    > But, I don't recommend you do this.


    If he doesn't want to write a file, then how about a pipe? For example in a
    system using "lpr":

    FILE *stdprn = popen("/usr/bin/lpr", "w");

    Scott
    --
    Scott Hemphill hemphill@alumni.caltech.edu
    "This isn't flying. This is falling, with style." -- Buzz Lightyear

  6. Re: printing from 'C'

    Scott Hemphill writes:
    >scott@slp53.sl.home (Scott Lurndal) writes:


    >>
    >> If you really want to talk directly to the printer bypassing the
    >> spooler and any filtering and ppd processing, you can:
    >>
    >> FILE *stdprn = fopen("/dev/lp", "w");
    >>
    >> But, I don't recommend you do this.

    >
    >If he doesn't want to write a file, then how about a pipe? For example in a
    >system using "lpr":
    >
    > FILE *stdprn = popen("/usr/bin/lpr", "w");


    Indeed, this would be suitable.

    scott


+ Reply to Thread