Answers for "create new file c++"

C++
0

create new file c++

#include <iostream>
#include <fstream>
using namespace std;

int main() {
  // Create and open a text file
  ofstream MyFile("filename.txt");

  // Write to the file
  MyFile << "Files can be tricky, but it is fun enough!";

  // Close the file
  MyFile.close();
Posted by: Guest on June-03-2020
1

create file c++

// using ofstream constructors.
#include <iostream>
#include <fstream>  

std::ofstream outfile ("test.txt");

outfile << "my text here!" << std::endl;

outfile.close();
Posted by: Guest on January-01-2021

Browse Popular Code Answers by Language