I have created a program to copy a certain base to different directories. Since I am doing this copying multiple times I made this program. However the program functions properly in the directory where the program exists. But it won't work in other directories, only an empty file is created.
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
string s;
cin>>s;
fstream base;
fstream dest;
base.open("base_layout.cpp",ios::in);
dest.open(s,ios::out);
string a;
while(getline(base,a)){
dest<<a<<"\n";
cout<<a;
}
base.close();
dest.close();
return 0;
}
The base file exists in the directory where the program exists. The input for the program is "filename.txt" (filename can be anything)