To construct and initialize a filebuf object.
basic_filebuf()
The constructor opens a basic_filebuf object and initializes it with basic_streambuf<charT, traits>() and if successful is_open() is false.
// The file ewl-test before operation contains.
// CodeWarrior "Software at Work"
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
char inFile[ ] = "ewl-test";
int main()
{
using namespace std;
FILE *fp = fopen( inFile, "a+");
filebuf in(fp);
if( !in.is_open() )
{ cout << "could not open file"; exit(1); }
char str[] = "\n\ttrademark";
in.sputn(str, strlen(str));
in.close();
return 0;
}
Result:
The file ewl-test now contains:
CodeWarrior "Software at Work"
trademark