0

I have a textfile as follows:

Value1 = windows
Value2 = Processor
Value3 = pwower plug

Right now i am retrieving complete file as follows:

std::ifstream myfile;
myfile.open( "D:\\values_user.txt", std::ios::in );

if( !(myfile.is_open()) )
{   std::cout << "Error Opening File";
std::exit(0);   }

std::string firstline;


while( myfile.good() )
{
    std::getline( myfile, firstline);
    std::cout<< "\n" << firstline <<"\n";
}

I want to retrieve window, processor and pwower plug i.e. just want to have values after '='. So, suggest me how can i achieve this.

anamika email
  • 327
  • 9
  • 21
  • 1
    Related: [Why is iostream::eof inside a loop condition considered wrong?](http://stackoverflow.com/q/5605125) checking `.good()` got the same problem as `.eof()`. Prefer putting the read in the loop condition. – AliciaBytes Aug 13 '15 at 10:52

1 Answers1

-1

Just Tokenize your string (firstline) basedd on the delimeter character (=, in your case).

Here is the example.

strtok

Ali Kazmi
  • 1,460
  • 9
  • 22