fstream - STL C++

wfilebuf

Declaration

typedef basic_filebuf<wchar_t, char_traits<wchar_t> > wfilebuf;

Description

This is the type definition of the wfilebuf type in the fstream header. The buffer supports reading and writing Unicode characters to a file.

Header Include

#include <fstream>

Example

#include <iostream>
#include <fstream>

int main() {
	using namespace std;

	wfilebuf qXoaXFile;
	// Open a Unicode text file. Create a new file if it does not exist.
	qXoaXFile.open("XoaX.txt", ios_base::out | ios_base::trunc);

	if (qXoaXFile.is_open()) {
		// Write the string into the file
		qXoaXFile.sputn(L"XoaX.net", 8);
		qXoaXFile.close();
		cout << "Wrote \"XoaX.net\" to the file \"XoaX.txt\"." << endl;
	} else {
		cout << "\"XoaX.txt\" failed to open" << endl;
		return -1;
	}

	// Keep the window open
	cin.get();
	return 0;
}

Output

wfilebuf Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.