|
From: Samuel K. <big...@ya...> - 2002-10-09 02:59:25
|
I am trying to learn how to send something to a
printer. I try to compile this .c file and dev
complains that there is a parsh error before '*' (on
the line where I declare FILE *fp =
fopen("LPT1","wt"); and then gives another error
because it thanks fp is a function.) Can anyone tell
me what I'm doing wrong in this code?
#include <conio.h>
char PrintBuf[5000]; // make it large enough!
int printer(const char *Format,...) //user defined
function
{
char *Ptr = PrintBuf+lstrlen(PrintBuf);
va_list arglist;
va_start(arglist,Format);
vsprintf(Ptr,Format,arglist);
va_end(arglist);
return printf(Ptr);
}
void main()
{
PrintBuf[0] = 0;
// your program runs here......
// just use printer() instead of printf.
// It will print text to screen and into the buffer
// example:
printer("\t\t\tS K DATABASE SOLUTIONS\n\n");
printer("\t\t\t=-=-=-=-=-=-=-=-=-=-=-\n\n");
printer("Employee ID: %d\n",1001);
printer("Employee Name:%s\n","Shashi");
printer("Employee Pay:%f\n",1000.75);
printer("-===-=-=-=-=-=-=-=-=-=-=-=-");
// Now print the buffer to the printer
FILE *fp = fopen("LPT1","wt");
if(fp)
{
fwrite(PrintBuf,1,lstrlen(PrintBuf),fp);
fputc('\f',fp); // add a formfeed for pageprinters
fclose(fp);
}
return 0;
}
__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com
|