Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 481
  • Last Modified:

Console App Printing using Borland C++ Builder 4.5

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
tinybear
Asked:
tinybear
  • 7
  • 3
1 Solution
 
tinybearAuthor Commented:
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
 
wendersonCommented:
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
 
tinybearAuthor Commented:
Cheers will give it a go when I get back home.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
tinybearAuthor Commented:
Hi,

Cant get it to work in Turbo C++

will try it in C++ Builder later

0
 
wendersonCommented:
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
 
tinybearAuthor Commented:
I'll get a full list of the errors when I get in to college later but..

The FILE keyword generates errors


0
 
tinybearAuthor Commented:
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
 
wendersonCommented:
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
 
tinybearAuthor Commented:
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
 
tinybearAuthor Commented:
Please Allocate Points to wenderson
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 7
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now