Have you forgotten to include a header file? Does conio.h have the FILE
declaration in it?
Also, your if statement ( if (fp) ), won't that return true is the pointer
is anything but null? Shouldn't it be *fp ? Or something?
>From: Samuel Keding <big...@ya...>
>To: dev...@li...
>Subject: [Dev-C++] printer
>Date: Tue, 8 Oct 2002 19:59:24 -0700 (PDT)
>
>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
>
>
>-------------------------------------------------------
>This sf.net email is sponsored by:ThinkGeek
>Welcome to geek heaven.
>http://thinkgeek.com/sf
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
_________________________________________________________________
Join the worlds largest e-mail service with MSN Hotmail.
http://www.hotmail.com
|