Solved

Console App Printing using Borland C++ Builder 4.5

Posted on 2002-03-10
10
458 Views
Last Modified: 2011-10-03
Hi,

I need to write to the printer froma Console App.

Previously when I used Turbo C++ the follwing worked

fprintf(stdprn,.....   etc

It doesnt in C++ Builder 4.5

How can I get round this. Any info would be useful..
0
Comment
Question by:tinybear
  • 7
  • 3
10 Comments
 

Author Comment

by:tinybear
ID: 6854360
BTW Im running C++ Builder on Win XP it that is relevant, but I would need it to work in Turbo C++ if possible as that is the compiler used by my college ( they have limited resources)
0
 

Expert Comment

by:wenderson
ID: 6854761
In a Windows program, you don't have theprinter file already open, so you can do the following:

FILE *stdprn = fopen("LPT1", "wt");
fprintf(stdprn, "Printing Test\n\n");

Wenderson

0
 

Author Comment

by:tinybear
ID: 6855513
Cheers will give it a go when I get back home.
0
 

Author Comment

by:tinybear
ID: 6855537
Hi,

Cant get it to work in Turbo C++

will try it in C++ Builder later

0
 

Expert Comment

by:wenderson
ID: 6855796
Why not? What's happening?
I tested it here and it works just fine.
Be aware that some printers just start printing when you send a full page or a eject page sinal.

Wenderson
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:tinybear
ID: 6855897
I'll get a full list of the errors when I get in to college later but..

The FILE keyword generates errors


0
 

Author Comment

by:tinybear
ID: 6856133
In Turbo C++ 3.0

When I compile with the FILE *stdprn = fopen("LPT1","wt")

The first error generated is

Cannot Convert 'FILE *' to 'FILE * &[4]'

and then several others.

0
 

Accepted Solution

by:
wenderson earned 50 total points
ID: 6858349
What version of Turbo C++ 3.0 are using, DOS or Windows?
The DOS version already has stdprn defined as a global variable, just include stdio.h.
There's no need to open the file, because it's already opened, just do:

#include <stdio.h>
int main()
{
  fprintf(stdprn, "Teste\n");
  return 0;
}

I don't remember if the Windows version has a stdprn defined, if not, you must do "FILE *stdprn = fopen("LPT1", "wt");" before you start printing.

Wenderson
0
 

Author Comment

by:tinybear
ID: 6859738
Yes it is the DOS version (the college really need to update), but I use Borland C+ Builder3 at home, so I need the program to work in both..which is my dilemma.

Maybe I'll just have to compile 2 versions.
0
 

Author Comment

by:tinybear
ID: 6863750
Please Allocate Points to wenderson
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now