I need to extract all the sequences of non-empty characters (i.e. words) from all lines in a ascii inp_file. The following code does not go beyond the very first non-empty string, i.e. item is repeatedly the very first word of the first line.
while (getline(inp_file, line)) {
while (istringstream(line) >> item) {
out_file << item << '\n';
}
}
I thought that istringstream applies the stream attributes to its argument, making it behaving like a stream.
What am I doing wrong? How can I extract all the words in inp_file?