Hey,
May someone please explain to me why the rename function isn't working? result should display a 0 if the files were sucessfully renamed. it keeps returning a -1.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
using namespace std;
int main(int argc, char *argv[])
{
bool Stats;
char *temp;
int result;
ifstream in1;
ofstream out1, out2;
in1.open(argv[1], ios::binary);
if (!in1)
{
cout << "That is not a valid file. Try again!\n";
}
else
{
temp = new char [strlen(argv[1]) + 5];
strcpy(temp, argv[1]);
strcat(temp, ".txt");
out1.open(temp, ios::binary);
Stats = FixFile(out1, in1);
remove(argv[1]);
result = rename(temp, argv[1]);
cout << result;
}
return 0;