okay,
I got another one for you. I thought windows would
create a file named LPT1 and put it in the directory
where I ran the .exe file. It didn't. I changed the
file name to USB1 and looked again. There was a file
named USB1 in the same directory as my .exe file.
When I write LPT1 though and run the .exe file, I have
to stop the program by going through ctrl alt del.
Nothing is ever printed, no file made, or if it is I
don't know where it is going. I'm confused. Here is my
source if it will help.
#include <conio.c>
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);
}
int main()
{
FILE* sfile;
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
sfile = fopen("LPT1","wt");
if(sfile)
{
fwrite(PrintBuf,1,lstrlen(PrintBuf),sfile);
fputc('\f',sfile); // add a formfeed for pageprinters
fclose(sfile);
}
return 0;
}
__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com
|