Last active
May 6, 2023 20:00
-
-
Save je4npw/f6afc07c1a70bda6d673790ab9ca8217 to your computer and use it in GitHub Desktop.
hello_world.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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