c++ - Read up to delimeter from a file -
i feel idiot having ask since i've been programming c++ years, can't figure out easiest/best way read data file. file structured so:
firstname lastname, num1 string1 num2 num3
the first , last name need stored in single string variable name
per program requirements. know can combine different string/file processing methods feel there's way in 1-3 lines of code i'm forgetting. i've tried either invalid or long. how read in?
std::getline
takes delimeter:
if (std::getline(is, name, ',') && std::getline(is, rest)) { // read both }
Comments
Post a Comment