Ok, I want to look through lines in a .txt file. I know how to search for a certain file. How would I scan a single line until eof?
Printable View
Ok, I want to look through lines in a .txt file. I know how to search for a certain file. How would I scan a single line until eof?
this reads in a line of code until the end of the line
ifstream fin("c:\\yourFileGoesHere");
string str;
getline(fin, str, '\n');
reads only a single line........
i just wrote this up.. hope it helps
#include <fstream.h>
#include <iostream.h>
void main()
{
char text1[5000];
char filename[30];
cout << "What file do you want to display?\n";
cin.getline(filename, 30, '\n');
ifstream file(filename);
do
{
file.getline(text1, 5000, '\n');
cout << text1;
cout << "\n";
}
while (file.eof()!=1);
file.close();
}