Skip to content

Instantly share code, notes, and snippets.

@je4npw
Last active May 6, 2023 20:00
Show Gist options
  • Save je4npw/f6afc07c1a70bda6d673790ab9ca8217 to your computer and use it in GitHub Desktop.
Save je4npw/f6afc07c1a70bda6d673790ab9ca8217 to your computer and use it in GitHub Desktop.
hello_world.cpp
#include <fstream>
#include <vector>
#include <string>
#include <sys/stat.h>
#include <filesystem>
using namespace std;
int main()
{
struct
{
string dir_name;
string file_name;
bool folder_exists;
vector<string> list;
} wl;
wl.dir_name = "/home/je4npw/exercicios";
wl.file_name = "exercicios.txt";
wl.list = {
"iqoeufoi",
"ajdschiuashgcuox",
"kjadscbhkasghcku",
"lasjhcljashclj",
"lahahclodshv",
"dklvnljkahdck",
"aljdchkjashcjlx",
"kljdchlahfdlc",
"alkschljahcla",
"kjdckscbjadh",
"akldvchljahc",
"alsghckiagsuxc",
"adkljvbhjkadhv"};
if (!filesystem::exists(wl.dir_name))
{
mkdir(wl.dir_name.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
}
ofstream file(wl.dir_name + "/" + wl.file_name);
for (int i = 0; i < wl.list.size(); i++)
{
file << wl.list[i] << endl;
}
file.close();
exit(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment