fbpx

C++: Create a File

Bjarne-stroustrup
 

In this task, the job is to create a new empty file called “output.txt” of size 0 bytes and an empty directory called “docs”. This should be done twice: once “here”, i.e. in the current working directory and once in the filesystem root.

#include <fstream>
#include <direct.h>

int main() {
	std::fstream f( "output.txt", std::ios::out );
	f.close();
	f.open( "/output.txt", std::ios::out );
	f.close();

	_mkdir( "docs" );
	_mkdir( "/docs" );

	return 0;
}

SOURCE

Content is available under GNU Free Documentation License 1.2.

Our team found a curious site for our readers that are fans of online gaming, a rather exciting site that provides the latest gaming technology. Casinodots.com is the site, they compile the best reviews of MGA casino utan svensk licens sites. This site might pique your curiosity and you can win extra money!