I created a small program to copy a certain base file to a new file in any directory using command prompt. But it is not working please help me?

  automation, c++, linux

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. Please help me out to solve this problem.

#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)

Source: Windows Questions C++

LEAVE A COMMENT