C++ Tutorial/File Stream/strstream
Perform both input and output
<source lang="cpp">#include <iostream>
- include <strstream>
using namespace std; int main() {
char iostr[80]; strstream strio(iostr, sizeof(iostr), ios::in | ios::out); int a, b; char str[80]; strio << "10 20 testing "; strio >> a >> b >> str; cout << a << " " << b << " " << str << endl; return 0;
}</source>
10 20 testing
Perform both input and output with strstream
<source lang="cpp">#include <iostream>
- include <strstream>
using namespace std; main() {
char iostr[80]; strstream ios(iostr, sizeof(iostr), ios::in | ios::out); int a, b; char str[80]; ios << "1734 534abcdefghijklmnopqrstuvwxyz"; ios >> a >> b >> str; cout << a << " " << b << " " << str << endl;
}</source>