Skip to content

Instantly share code, notes, and snippets.

@artemp
Created May 10, 2013 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artemp/45d5d82ed5696978e7c4 to your computer and use it in GitHub Desktop.
Save artemp/45d5d82ed5696978e7c4 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
#include <sstream>
int main(int argc,char** argv)
{
std::ostringstream out;
char * str = "ABCD-";
out.write(str,5);
out.write(str,5);
out.write(str,5);
std::cerr << out.tellp() << std::endl;
std::cerr << "seek 5" << std::endl;
out.seekp(5, std::ios::beg);
std::cerr << out.fail() << " " << out.good() << " " << out.eof() << std::endl ;
std::cerr << out.tellp() << std::endl;
std::cerr << "seek 15" << std::endl;
out.seekp(15,std::ios::beg);
std::cerr << out.fail() << " " << out.good() << " " << out.eof() << std::endl ;
std::cerr << out.tellp() << std::endl;
std::cerr << "seek 25" << std::endl;
out.seekp(25, std::ios::beg);
std::cerr << out.fail() << " " << out.good() << " " << out.eof() << std::endl ;
std::cerr << out.tellp() << std::endl;
std::cerr << "seek 10" << std::endl;
out.seekp(10, std::ios::beg);
std::cerr << out.fail() << " " << out.good() << " " << out.eof() << std::endl ;
std::cerr << out.tellp() << std::endl;
std::cerr << out.str() << std::endl;
return EXIT_SUCCESS;
}
@artemp
Copy link
Author

artemp commented May 10, 2013

clang version 3.3 (179091)
Target: x86_64-apple-darwin12.3.0
Thread model: posix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment