#include <iostream>
#include <string>
#include <fstream>
using namespace std ;
string strWord( int index , string line)
{
int count = 0;
string word;
for ( int i = 0 ; i < line.length(); i++)
{
if ( line[i] == ' ' )
{
if ( line [i+1] != ' ')
{
count ++;
if ( count == index)
{
return word;
}
word ="";
}
}
else
{
word += line[i];
}
}
}
int main ( )
{
ifstream inFile ;
inFile.open("new.txt");
string line , id;
cout <<"Enter id : ";
cin >>id;
while(!inFile.eof() )
{
getline ( inFile , line );
if ( strWord ( 1, line ) == id )
{
cout <<strWord ( 2 , line ) <<endl;
break;
}
}
system("pause");
}
Question is : Can someone explain this to me I do not get what it is doing i mean i get the concept but what is each line doing?