Solved

How to make a program to read txt files

Posted on 2000-04-14
8
227 Views
Last Modified: 2010-04-10
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
Comment
Question by:Blocker
8 Comments
 
LVL 1

Expert Comment

by:tvanceplus
ID: 2717705
Look into a the fstream class collection.
0
 
LVL 32

Expert Comment

by:jhance
ID: 2717985
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
 
LVL 22

Expert Comment

by:nietod
ID: 2718214
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
 

Expert Comment

by:Bknight9
ID: 2718326
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 33

Expert Comment

by:hongjun
ID: 2718484
I feel that this is a school assignment.

hongjun
0
 

Author Comment

by:Blocker
ID: 2718869
Edited text of question.
0
 
LVL 22

Accepted Solution

by:
nietod earned 50 total points
ID: 2718950
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
 

Author Comment

by:Blocker
ID: 2718971
thats just what i wanted thanck you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AVI wait icons for CAnimateCtrl in Visual Studio 2008 MFC 1 119
is twain_32.dll cmpatible with windows 10 ? 10 123
I could not build boost code, 10 78
Issues with C++ Class 19 78
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
  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 video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

932 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

9 Experts available now in Live!

Get 1:1 Help Now