c++ files
// basic file operations
#include <iostream>
#include <fstream>
using namespace std;
int main () {
ofstream myfile;
myfile.open ("example.txt");
myfile << "Writing this to a file.\n";
myfile.close();
return 0;
}
c++ files
// basic file operations
#include <iostream>
#include <fstream>
using namespace std;
int main () {
ofstream myfile;
myfile.open ("example.txt");
myfile << "Writing this to a file.\n";
myfile.close();
return 0;
}
how to run cpp file
# Open Terminal:
# Type:
g++ --version
# If the command is not recognized:
sudo apt-get install g++
g++ --version # should work now
# If the command is recognized
mkdir tmp
cd tmp
touch main.cpp
# open main.cpp using vi, vim, gedit, etc
# Type in a hello world program:
# https://www.tutorialspoint.com/cplusplus-hello-world-program
# Once this has been done, type in:
g++ main.cpp
./a.out
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us