hi everyone , i have to read a text file containing 2 columns , 1 is sort of the instruction and 2nd is the string involced. so i used istringstream for that and it worked fine. the problem is it only read the first words. can someone please help to explain to me . below is the sample of the text file
1 2 3 4
apple this is sweet
banana yellow
orange buy from market
apple red
it can successfully read the 2nd column but only the first word, not the succeeding
Please consider what I have done in my example: in >> item >> ws (which gets the first word into the string variable item, and skips the next whitespace)
followed by getline( in, description ) (which puts the rest of the line into the string variable description).
This should meet your needs. How you output item and description afterwards is entirely up to you.