Basically this program searches a .txt file for a word and if it finds it, it prints the line and the line number. Here is what I have so far.
Code:
#include "std_lib_facilities.h"
int main()
{
string findword;
cout << "Enter word to search for.\n";
cin >> findword;
char filename[20];
cout << "Enter file to search in.\n";
cin >> filename;
ifstream ist(filename);
string line;
string word;
int linecounter = 1;
while(getline(ist, line))
{
if(line.find(findword) != string::npos){
cout << line << " " << linecounter << endl;}
++linecounter;
}
keep_window_open();
}
Solved.