Hi :)

I am using TurboC++ IDE 3.0. I need to open a file and display the contents of this file on the screen. My problem is simple... i need to open a file and display its contents in graphics mode.. so that i can display it using outtextxy() ...is that possible?If thats not possible... is there any other way i can do this?

I am switching between text and graphics mode using setgraphmode() and restorecrtmode().

Of course its possible, but I don't remember how to do it because that compiler you are using is about 20 years old (maybe more) and is only used nowdays as a toy for kids to play around with. Anyone who really wants to learn how to program would use one or more of the many free modern compilers available today. Afterall, you can't learn to drive your dad's car by first riding a horse.

Of course its possible, but I don't remember how to do it because that compiler you are using is about 20 years old (maybe more) and is only used nowdays as a toy for kids to play around with. Anyone who really wants to learn how to program would use one or more of the many free modern compilers available today. Afterall, you can't learn to drive your dad's car by first riding a horse.

I agree, but its unfortunate that few schools like ours still insist on "riding a horse". And i have no choice but do what i am supposed to. So, any help u can provide would be appreciated.

A few questions for your college / tutor.

Why are you teaching using tools, languages and operating systems which are at least 15 years out of date?

How do you consider this to be an effective preparation for the world after leaving college?

Have you ever had feedback from recent ex-students as to how they found the course, and how well it prepared them for their career?

When was the last time the curriculum was revised to meet the modern demands of students and prospective employers. When is the next such review due?

With the prevalence of many excellent, up to date and most importantly, free tools available, what other reasons are there for sticking with the old tools?

Regardless of whatever waffle you get in response, one likely reason is that the tutors themselves don't know enough C++ to move away from their comfort zone of that particular compiler. Their lack of real C++ knowledge would be exposed were they to use another compiler. It's easy to come to this conclusion because of all the "well my tutor said..." rubbish which is reported by students when we correct them here on the message board.

> so that i can display it using outtextxy() ...is that possible?
Of course it is.
If you've already managed to display a fixed string, then replacing that with a char array filled with data read from a file should be a breeze.
What exact problems are you facing?

Comments
I hope that if you have a kid who is doing a programming class and the teacher is an idiot you'll record the conversation you have with them for us all to see.
Worth reading.

I agree, but its unfortunate that few schools like ours still insist on "riding a horse". And i have no choice but do what i am supposed to ...

"Don't let school get in the way of your education." ~Samuel Langhorne Clemens~
What would prevent you from installing a modern compiler and trying to learn by your own, if that is what's required for you to learn correctly? Giving to Cesar what's Cesar's and to you what you need in order to succeed?

"Don't let school get in the way of your education." ~Samuel Langhorne Clemens~
What would prevent you from installing a modern compiler and trying to learn by your own, if that is what's required for you to learn correctly? Giving to Cesar what's Cesar's and to you what you need in order to succeed?

He needs to write a program using BGI graphics for school. He never said anything about not using a modern compiler in his free time.

He needs to write a program using BGI graphics for school.

You earned yourself an A- for writing it "in your own words".

He never said anything about not using a modern compiler in his free time.

No. Never, she/he neither said anything about if she/he prefers a "burrito" from Taco Bell or a "Big Mac" from MacDonald's. What's your point?
Only a student sees "free time" as a real concept.

What's your point?

My point is, what makes you think the OP hasn't already a modern compiler installed. Go back and read the thread because you've lost the plot.

My point is, what makes you think the OP hasn't already a modern compiler installed.

Thinking? No. No assumptions in my part. Just two rhetoric questions based on this comment;

Hi :) I am using TurboC++ IDE 3.0.

and on this one.

I agree, but its unfortunate that few schools like ours still insist on "riding a horse". And i have no choice but do what i am supposed to.

I too fail to see how complaining about the OP's tools helps him answer his question. There is no need to give him/her a hard time.

In the real world of capitalism, choice of toolset is entirely dictated by business concerns. Nothing else. Business [or school] issues dominate technical issues. Period.


stackOverflow
There are three answers to your problem --two that you have already found.

  1. Use outtext and/or outtextxy along with setviewport to draw the text graphically on the screen but keep it bounded into an area. You will probably also find the textwidth and textheight functions useful.
  2. Switch to text mode to display it, and return when done.
  3. Use the BIOS functions to dump the text onto the screen. Even though you are in a graphics mode, the video BIOS can still write to the screen as if it were a TTY.

For option 1, you might want to check out this thread, where that OP had a similar question.

Hope this helps.

Yes Aia, and then I pointed out you never took into consideration, the OP must use BGI graphics for this program rendering those questions irrelevant.

Ok people -- stop arguing about something not relevant to the topic or helpful to the op.

>>that i can display it using outtextxy() ...is that possible
Yes -- as Salem and Duoas have already mentioned. Displaying the text from a file should not be difficult unless you want to do fancy things such as color coding, changing font sizes and paginating.

This question has already been answered. Start a new discussion instead.