0

How I can read line of a file with a whitespace, in the case that faddress was a string with space I will not able to read all the line.

What I can do ? I try using noskipws but it doesn't work

http://www.cplusplus.com/reference/ios/noskipws/

Code:

ifstream rFile;
rFile.open("list_of_people.txt");

 while(rFile  >> fname >> flastName >> ocupation>> faddress >> age){
            insert(fname,flastName,ocupation,faddress,age);
         }

File :

John Smith Engineer Av Roses 25

1 Answers1

0

You could use std::getline() to have the entire line in a string, then use string functions to parse it / tokenize it as you see fit. About doing that, see, for example:

Parse (split) a string in C++ using string delimiter (standard C++)

einpoklum
  • 118,144
  • 57
  • 340
  • 684