A
Adrian
What is a stringsteam supposed to do when you seek past the end of
existing buffer. I can seek past the end of a file stream (my
implementation fills the space will nulls but I cannot find if this is
guaranteed either)
Below code fails for a stringstream. Any good ways of dealing with
this.
Reason for doing this is that I am modify old C code for screen output
that positions fields based on a row. I wanted to use a stringstream
and just seek to the correct place.
I have tried basically filling the stream with X spaces first. But
then I am never sure there is enough space.
Any help appreciated.
Adrian
#include <iostream>
#include <sstream>
#include <fstream>
int main(int argc, char *argv[])
{
std:
fstream out("test.txt");
out.seekp(500);
out << "some text\n";
std:
stringstream out2;
out2.seekp(500);
out2 << "some text\n";
if(!out2)
{
std::cout << "bad out2\n";
}
return 0;
}
existing buffer. I can seek past the end of a file stream (my
implementation fills the space will nulls but I cannot find if this is
guaranteed either)
Below code fails for a stringstream. Any good ways of dealing with
this.
Reason for doing this is that I am modify old C code for screen output
that positions fields based on a row. I wanted to use a stringstream
and just seek to the correct place.
I have tried basically filling the stream with X spaces first. But
then I am never sure there is enough space.
Any help appreciated.
Adrian
#include <iostream>
#include <sstream>
#include <fstream>
int main(int argc, char *argv[])
{
std:
out.seekp(500);
out << "some text\n";
std:
out2.seekp(500);
out2 << "some text\n";
if(!out2)
{
std::cout << "bad out2\n";
}
return 0;
}