<EDIT: uhm, the following is in reply to post#3, of course>
yes, and I already explained why getline does not work with your code, it's because of the way you're initializing the stringstream. Consider the following:
this won't work, outputting "text10". But this:Code:std::istringstream iss( "text10\0text20\0text30\0text40\0text50\0text60\0" ); int main() { std::string buffer; while( std::getline( iss, buffer, char() ) ) { std::cout << buffer << std::endl; } }
works as expected.Code:char iss_buf[] = "text10\0text20\0text30\0text40\0text50\0text60\0"; std::istringstream iss( std::string( iss_buf, sizeof(iss_buf) ) ); int main() { std::string buffer; while( std::getline( iss, buffer, char() ) ) { std::cout << buffer << std::endl; } }




Reply With Quote