stream - C++: how do I create istream with desired content? -
i given function following signature. can't change it, have work it.
void parse(std::istream & in); i'm supposed test function, call predefined content , check if values parsed. therefore need call function... parse("abcdedf....")... wasn't able to find way how it.
i'm new c++ may dumb question. far understand streams, istream when reading source, file example. need turn regular string source don't know how.
use string stream:
std::istringstream iss("abcdef...."); parse(iss); like std::ifstream, used reading in files, std::istringstream derives std::istream, can upcast std::istringstream & std::istream & pass in.
Comments
Post a Comment