Well, this is the solution.

#include <iostream> #include <cstdio> #include <fstream> #include <string> using namespace std; int main() { string address; string newname;

Here you can see I used strings instead of char arrays.

char input; int action; char confirm; int result; cout << "File Manipulator 1.0" << endl; cout << "--------------------" << endl << endl; cout << "Type the full address of a file you wish to manipulate." << endl << endl; getline(cin, address); ifstream myfile(address.c_str());

I used ifstream with c_str() function which passes contents of a std::string into a C style string.

// try to open the file if (myfile.is_open()) {

When the condition is met, you must close the opened file in order to be able to manipulate/work with it later.

myfile.close(); CREATE:cout << endl << "-----------------------------------" << endl; cout << "Type 1 to move the selected file." << endl; cout << "Type 2 to rename the selected file." << endl; cout << "Type 3 to delete the selected file." << endl; cout << "-----------------------------------" << endl << endl; cin >> action; switch (action) { case 1: { // do nothing. } break; case 2: { // rename file. cout << "Enter the new name" << endl << endl; cin.ignore();

I used here the ignore() function to ignores the amount of characters I specify when I call it.

getline(cin, newname); cout << "Are you sure you want ot rename the selected file ? Y/N" << endl << endl; cin >> confirm; if (confirm == 'Y' || confirm == 'y') {

Same case with c_str() that i explained earlier.

rename(address.c_str(), newname.c_str()); } } break; case 3: { // delete file. remove(address.c_str()); } break; default: { cout << "You typed an invalid command!" << endl; } break; } } else { cout << "The selected file does not exist! Would you like to create it? "; cin >> input;

If the file name you input doesn't exist, you are prompted to create a file with the specified name, then you are redirected with goto to the manipulation menu.

if (input == 'y' || input == 'Y') { // create the file. ofstream output(address.c_str()); output.close(); cout << "File created"; goto CREATE; } } return 0; }

Thanks for trying anyway :)