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

How to choose a certain line to output

This topic is 2837 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 2837 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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!