fstream - STL C++

wofstream

Declaration

typedef basic_ofstream<wchar_t, char_traits<wchar_t> > wofstream;

Description

This is the type definition of the wofstream type in the fstream header.

Header Include

#include <fstream>

Example

#include <iostream>
#include <fstream>

int main() {
	using namespace std;

	// Open the output file stream for writing
	wofstream qXoaXFile;
	qXoaXFile.open("XoaX.txt");

	if (qXoaXFile.is_open()) {
		// Write to the file
		qXoaXFile << L"XoaX.net";
		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

wofstream Output
 

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