Solved

Console App Printing using Borland C++ Builder 4.5

Posted on 2002-03-10
10
454 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
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 technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

706 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

19 Experts available now in Live!

Get 1:1 Help Now