Solved

Console App Printing using Borland C++ Builder 4.5

Posted on 2002-03-10
10
472 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: 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!

 

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
 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
  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 goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

734 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