// Showing try and catch for writeing to a file.
// By DreamVB 18:06 02/11/2016

#include <iostream>
#include <fstream>

using namespace std;
using std::cout;
using std::endl;

int main(int argc, char *argv[]){
	char *lzout = "C:\\Test\\testfile.txt";

	fstream fs;
	try{
		fs.open(lzout, ios::out);

		//Check if file was opened.
		if (!fs){
			throw ios::failure(string("Error Writeing to Output File."));
		}
		else{
			//Write some data to the file.
			fs << "This is an example of writeing data to a text file." << endl;
			//Close the file.
			fs.close();
		}
	}
	catch (std::exception& e){
		cout << typeid(e).name() << endl << e.what() << endl;
	}

	system("pause");
	return 0;
}