I have written a program which executes an application (netview) and logs the output into a text file.Later I open and read this file line by line using getline() function.Now I need to check whether a particular word exists in the line read from the text file.Plz help...
Below is my coding:
#include <stdio.h>
#include <dos.h>
#include <stdlib.h>
#include <time.h>
#include <conio.h>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
FILE *fp;
char fln[100]="net view >test.txt";
char fln2[100];
void main()
{
for(;;)
{
fp = fopen("create_dir.bat","w");
sprintf(fln2,"@echo OFF\n %s",fln);
fputs(fln2,fp);
fclose(fp);
system("create_dir.bat");
system("del create_dir.bat");
string line;
ifstream myfile ("test.txt");
if (myfile.is_open())
{
while (! myfile.eof() )
{
getline (myfile,line);
cout <<line<<endl;
}
myfile.close();
}
else cout << "Unable to open file";
}
}
Thank You,
Rajeev Nair.