M
mathieu
Hi there,
I think I misunderstood the purpose of std::fstream::seekp. I would
like to append data at the end of a file. So I wrote the following
piece of code (*).
It prints '0' in my console, which means the call to seekp(0,
std::ios::end) did not seek to the end of the file. How am I supposed
to do that in a portable way ? (no such thing as std::ios::app)
Thanks,
#include <fstream>
#include <iostream>
int main()
{
const unsigned int len = 512;
char buffer1[len] = {};
char buffer2[len] = {};
{
std:
fstream of( "dummy.raw", std::ios::binary );
of.write( buffer1, len );
of.close();
}
{
std:
fstream of( "dummy.raw", std::ios::binary );
of.seekp( 0, std::ios::end );
std::cout << of.tellp() << std::endl;
of.write( buffer2, len );
of.close();
}
}
I think I misunderstood the purpose of std::fstream::seekp. I would
like to append data at the end of a file. So I wrote the following
piece of code (*).
It prints '0' in my console, which means the call to seekp(0,
std::ios::end) did not seek to the end of the file. How am I supposed
to do that in a portable way ? (no such thing as std::ios::app)
Thanks,
#include <fstream>
#include <iostream>
int main()
{
const unsigned int len = 512;
char buffer1[len] = {};
char buffer2[len] = {};
{
std:
of.write( buffer1, len );
of.close();
}
{
std:
of.seekp( 0, std::ios::end );
std::cout << of.tellp() << std::endl;
of.write( buffer2, len );
of.close();
}
}