Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
Stream generalization
#include <iostream> #include <istream> #include <fstream> #include <sstream> #include <memory> #include <string> std::string foo(std::istream& i) { std::string line; while (std::getline(i, line)) { std::cout << "line: " << line << "\n"; } return line; } int main() { char buffer[] = "I'm a buffer with embedded nulls\nand line\n feeds\0"; std::istringstream stream(buffer); foo(stream); std::fstream fileStream; foo(fileStream); }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
temp
iuadhfaoiufs
Hashing
Quadratic Equation
TwoVarRegression
template
Rotate array
cppOverride
pbds
27
stackse - search stackoverflow differently
Please log in to post a comment.