16 #include <boost/iostreams/stream_buffer.hpp> 18 namespace bios = boost::iostreams;
21 int main(
int argc,
char *argv[]) {
26 cerr <<
"\nSyntax:\n\t" << argv[0] <<
" <file name>\n" << endl;
33 fp = fopen(argv[1],
"w");
39 bios::stream_buffer<mds_fu::cFile_Sink> sbuf;
49 ofs.exceptions(ios::failbit | ios::badbit);
54 ofs.write(reinterpret_cast<char*>(&val),
sizeof(
double));
66 ofs <<
"This is a test string" << endl;
72 ofs.seekp(-5,ios::cur);
75 ofs <<
"word" << endl;
78 fclose(fp); fp = NULL;
84 fp = fopen(argv[1],
"ab");
99 ofs.seekp(-3,ios::end);
101 ofs <<
"Des" << std::endl;
105 fclose(fp); fp = NULL;
112 fp = fopen(argv[1],
"rb");
118 bios::stream_buffer<mds_fu::cFile_Source> sbuf2;
128 ifs.exceptions(ios::badbit | ios::failbit);
131 ifs.seekg(-4,ios::end);
138 cout <<
"Read string: " << str << endl;
141 ifs.seekg(0,ios::beg);
144 ifs.read(reinterpret_cast<char*>(&val),
sizeof(
double));
146 cout <<
"Value read: " << val << endl;
148 fclose(fp); fp = NULL;
Source device for FILE* pointers.
Sink device for FILE* pointers.
Contains some Boost.Iostreams devices to use a C FILE* as a C++ std::stream.
Namespace of all Michele De Stefano's C++ file utilities.