Reading a string from file c++

To read a whole line, use

std::getline(nameFileout, item_name)

rather than

nameFileout >> item_name

You might consider renaming nameFileout since it isn’t a name, and is for input not output.

Leave a Comment