I try to read several lines from a textfile and want to store the single items in a struct. The code looks like this:
std::string line;
struct _DomainTable_ line_of_file;
while (getline(infile_, line))
{
std:: stringstream linebuffer(line);
line_of_file.short_ = "";
line_of_file.long_ = "";
linebuffer >> line_of_file.id_ >> line_of_file.short_ << line_of_file.long_;
domain_list_.push_back(line_of_file);
it_++;
}
The single items in my text file are seperated by a blank. Unfortunately my program ignores the second blank between the second and the thrid column, so that the whole text after the "id_" is stored in "short_". Perhaps someone knows a better method to read a formatted file (such as scanf in C). I am workimg with C++ builder, and rather I don't want to use C anymore.
best regards and thank you very much Andreas Höhenberger