#include <iostream>
#include <fstream>
using namespace std;
int main()
{
// Writing to a file
ofstream outFile;
outFile.open("Test.txt");
outFile << "This is a test from CLion!" << endl;
outFile.close();
// Reading from a file
ifstream inFile;
inFile.open("Test.txt");
if (inFile.is_open())
{
// Move the cursor of the file to the end of the file
inFile.seekg(0, std::ifstream::end);
// Give the position of the current character
int length = static_cast<int>(inFile.tellg());
// Move cursor to the start of the file
inFile.seekg(0, std::ifstream::beg);
// Output buffer
char *buffer = new char[length + 1];
inFile.get(buffer, length);
cout << buffer << endl;
delete[] buffer;
inFile.close();
}
return 0;
}