1
This works, creates a file and puts what I want inside it:
#include <fstream>
#include <vector>
using namespace std;
int main() {
ofstream arquivo;
arquivo.open("arquivo.txt");
vector<string> v;
v.push_back("linha1");
v.push_back("linha2");
v.push_back("linha3");
if(arquivo.is_open()){
for(auto n: v) { arquivo << n << endl; }
}
}
But this does not work, if I want to create a new file inside a folder called "folder", it does not give error, just does not create the file. Does absolutely nothing:
#include <fstream>
#include <vector>
using namespace std;
int main() {
ofstream arquivo;
arquivo.open("pasta/arquivo.txt");
vector<string> v;
v.push_back("linha1");
v.push_back("linha2");
v.push_back("linha3");
if(arquivo.is_open()){
for(auto n: v) { arquivo << n << endl; }
}
}