I want to read each line of txt file which resembles something like this
1190/2132 123/23123 45
I want to read the whole line and then store them in three separate strings for future use to build a tree . I am using fgets right now , but getting errors regarding putting it into a string . How should i do it ?
Try this:
std::string line;
while(std::getline(file, line))
{
std::stringstream linestream(line);
std::string word1, word2, word3;
line >> word1 >> word2 >> word3;
// Store words
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With