Jump to content
  • Advertisement
Sign in to follow this  
D-Schade

How to choose a certain line to output

This topic is 2748 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone i got a problem with using ifstream to read a certain line i have in a text file.
Say i have a text file with three word's.

Jim
Bob
Sam

Well what i want to do is call a char,string,line or paragraph from a file.
Here is the basic code for loading a file.


#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main()
{
string line;
ifstream myfile ("des.txt");
if (myfile.is_open())
{
while (myfile.good())
{
getline (myfile,line);
cout << line << endl;
}
myfile.close();
}
else cout << "Unable to open file";

system("pause");
}


Share this post


Link to post
Share on other sites
Advertisement

This topic is 2748 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!