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. File vs Buffer

File vs Buffer

Scheduled Pinned Locked Moved C / C++ / MFC
questionvisual-studiosysadmin
1 Posts 1 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.
  • C Offline
    C Offline
    color Aljechin
    wrote on last edited by
    #1

    In the following code, I am trying to switch between monitor and printer as the default output device. (The code is executed in a server and the client is a dumb terminal. Hence the server instructs the client to print by switching the output device) I have some binary data(unsigned char) which I can dump into the printer buffer and it will print some meaningful text. If I write this data to a file, then read it and print it (The following code) it works. I dont want to use a file. I want to print it from that buffer in which I have the binary value. I the data is automatically converted to unsigned int or something when its written into file. How do I achieve this? int main(int argc, char *argv[]) { int ch; FILE *fp; fp=fopen(argv[1], "r");//open the file ansi_printer_on();//default device is printer now while ((ch=getc(fp))!=EOF) { putc(ch,stdout); } fclose(fp); ansi_printer_off();//default device is monitor now return 0; } :rose:

    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