• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 280
  • Last Modified:

How to make a program to read txt files

I need to make a program in c++ (dos) that can read txt file's and desply them. It also needs a menu at the top for the user to puck what file to read..

thx

blocker

I will add this after people have sead it THIS IS HOT HOMEWORK
0
Blocker
Asked:
Blocker
1 Solution
 
tvanceplusCommented:
Look into a the fstream class collection.
0
 
jhanceCommented:
What gives here?  

This is so trivial I suspect that it is some sort of homework assignment.

Did you read the Experts Exchange Policies?
0
 
nietodCommented:
Homwork with a menu?  Probably not.   possibly not?

Blocker, if this is for school, we cannot _give_ you the answer, but we can provide limited assistance.  

If it is not for schoole, we still can't provide the answer--in this case.  This is because a standard C++ program can't have menus.  You need to use non-standard OS-specific features to have menus, like features in the Windows API.  But those sorts fo things are not available in DOS.  We can show you how to read from a file, but the menu part is (nearly) impossible to do  (from DOS).
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Bknight9Commented:
You can use menus from DOS by using turbo vision from Borland. As for reading the txt file, you should use the fstream class.
0
 
hongjunCommented:
I feel that this is a school assignment.

hongjun
0
 
BlockerAuthor Commented:
Edited text of question.
0
 
nietodCommented:
What do you want to do about the menu part?  Realistically you can't have a menu in DOS (not without lots of work, or pehpas with turbo vision, if you have it, and now how to use it.)

to read a file and display it, just do.

fstream Fil("c:\somefile.txt",ios:in);

while (true)
{
   char Chr;
   Fil >> Chr; // Read a character from the file.
   if (Fil.eof()) // If at the end of the file, then
       break; // stop processing.
   cout << Chr; // Write the character to the screen.
}
0
 
BlockerAuthor Commented:
thats just what i wanted thanck you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

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