Search
 
SCRIPT & CODE EXAMPLE
 

CPP

How to write into files in C++

#include <fstream> 

/*
ofstream 	Creates and writes to files
ifstream 	Reads from files
fstream 	A combination of ofstream and ifstream: creates, reads, and writes to files
*/

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();
} 
Comment

PREVIOUS NEXT
Code Example
Cpp :: how to create a copy constructor for generic array class in c++ 
Cpp :: C++ sqlite open file in other directory 
Cpp :: what are various sections of process 
Cpp :: filling dynamic array with a specific value in c++ 
Cpp :: matrix layout in C++ 
Cpp :: change int to string cpp 
Cpp :: count function vector c++ 
Cpp :: factore of 20 in c+ 
Cpp :: qt qimage load from file 
Cpp :: stl for sorting in c++ 
Cpp :: taking user input for a vector in c++ 
Cpp :: c++ program to add two numbers using function 
Cpp :: fast io c++ 
Cpp :: crypto npm random bytes 
Cpp :: c++ std::copy to cout 
Cpp :: c++ virtual function in constructor 
Cpp :: prime number in c++ 
Cpp :: helloworld in c++ 
Cpp :: insertion sort c++ 
Cpp :: time delay in c++ 
Cpp :: lcm function c++ 
Cpp :: c++ check if string is empty 
Cpp :: delete last char of string c++ 
Cpp :: how to string to integer in c++ 
Cpp :: http.begin arduino not working 
Cpp :: run c++ program in mac terminal 
Cpp :: memcpy c++ usage 
Cpp :: file open cpp 
Cpp :: sieve cpp 
Cpp :: Story of c++ 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =