hello there, i have here a program(linux based) that creates a directory then transfer files to that said directory...the problem is, im using strcat to join my bash script commands to the users inputs..now, i have a loop that concatenates the commands...
is there a way that a concatenation will refresh in a loop...here's my program...
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <cstring>
using namespace std;
int main(){
char filename[50];
char directory_name[50];
char destination[50]= "cp ";
char mkdir_comm[50]= "mkdir ";
string destination_storage[50];
int number_of_files;
cout << "Enter directory name: ";
cin >> directory_name;
cout << "\n";
strcat ( mkdir_comm, directory_name);
(const char)*mkdir_comm;
system(mkdir_comm);
cout << "Directory successfully created: \n";
cout << "\n";
system("ls -l");
cout << "How many files do you want to transfer?:\n ";
cin >> number_of_files;
for(int i=0; i<number_of_files; i++){
cout << "Enter filename " << i+1 << ": ";
cin >> filename;
strcat( destination, filename );
strcat( destination, " ");
strcat( destination, directory_name);
(const char)*destination;
system(destination);
}
}
the cp command will ignore the commands on the 2nd loop because the concatenation does not refresh...help pls...