Alright I am trying to read from one file and write to another.
I have other things to add such as grabbing info from the first file but for testing I am trying to get it to write to the second file.
My understanding was that everything after the dp2() call would output to the second param. Right?
using namespace std;
using std::string;
using std::ostream;
using std::endl;
string str;
int main(){
int file= open("./input.txt", O_CREAT | O_RDWR | O_APPEND, S_IRUSR | S_IWUSR);
if(file==-1){
cout<<"Error: "<<errno<<endl;
}
int file2= open("./output.txt", O_CREAT | O_RDWR | O_APPEND, S_IRUSR | S_IWUSR);
if(file2==-1){
cout<<"Error: "<<errno<<endl;
}
int retval = dup2(file,file2);
if(retval == -1){
cout<<"Error: "<<errno;
}
printf("yeah");
close(file);
}