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