Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Printing from a C program

Printing from a C program

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++comhelp
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sayan Mukherjee
    wrote on last edited by
    #1

    Hi, I am using VC++ 6.0 . I need to print some text from a simple C program. How do I do it? I tried to use fprintf(); but couldn't get a suitable FILE * object to put as the first parameter. Please help. Is there any other way to do it? With best regards, Sayan Email:sayanmukherjee@indiatimes.com

    J J 2 Replies Last reply
    0
    • S Sayan Mukherjee

      Hi, I am using VC++ 6.0 . I need to print some text from a simple C program. How do I do it? I tried to use fprintf(); but couldn't get a suitable FILE * object to put as the first parameter. Please help. Is there any other way to do it? With best regards, Sayan Email:sayanmukherjee@indiatimes.com

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      printf (without the leading f.) Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

      S 1 Reply Last reply
      0
      • J Joaquin M Lopez Munoz

        printf (without the leading f.) Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

        S Offline
        S Offline
        Sayan Mukherjee
        wrote on last edited by
        #3

        By the word 'printing', I meant printing to a printer. With best regards, Sayan Email:sayanmukherjee@indiatimes.com

        J R 2 Replies Last reply
        0
        • S Sayan Mukherjee

          By the word 'printing', I meant printing to a printer. With best regards, Sayan Email:sayanmukherjee@indiatimes.com

          J Offline
          J Offline
          Joaquin M Lopez Munoz
          wrote on last edited by
          #4

          Oh I see... Well, if you can get by with a simple hack, redirect your standard output to the printer at the command line with myprogram >LPT1: or whatever your printer port is named (go to Control Panel->Printers->Properties->Details.) Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

          1 Reply Last reply
          0
          • S Sayan Mukherjee

            By the word 'printing', I meant printing to a printer. With best regards, Sayan Email:sayanmukherjee@indiatimes.com

            R Offline
            R Offline
            Ravi Bhavnani
            wrote on last edited by
            #5

            You could try this:

            FILE* pPrinter = fopen ("LPT1:", "w");
            if (pPrinter != NULL) {
            printf (pPrinter, "A line of text\n");
            fclose (pPrinter);
            }

            /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com

            1 Reply Last reply
            0
            • S Sayan Mukherjee

              Hi, I am using VC++ 6.0 . I need to print some text from a simple C program. How do I do it? I tried to use fprintf(); but couldn't get a suitable FILE * object to put as the first parameter. Please help. Is there any other way to do it? With best regards, Sayan Email:sayanmukherjee@indiatimes.com

              J Offline
              J Offline
              James R Twine
              wrote on last edited by
              #6

              Sayan Mukherjee wrote: I need to print some text from a simple C program. How do I do it?    If when you say "print" you mean console, you can use puts(...) or the "stdout" file handle with fprintf(...), fputs(...), etc.    If you mean "printer", you may be able to use the stdprn file handle.    Peace! -=- James.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups