I'm very new at C++ and would like to know how I would change a directory via user input? This will be a Win32 Project and not a Win32 application.

I know I can use (as standard - and without user input) the chdir("\\dir"); - but how do I use this with user input?

Thanks in advance! :)

usethe string header so you can get the path from the user then pass it to chdir like this

chdir(path.c_str());

Chris

Thanks for your reply!!

Sorry if I am being thick, but is this correct (some of the script has been removed)?

#include <string.h>

using namespace std;

string entry;

cout << "1. Enter FULL PATH to directory: ";
cin >> entry;

chdir(path.entry_str());

cin.get();

	return 0;
}

Thanks again for your help!

Hi,

Thank you very much for that. It now works!!!!

Using:

string user;
string entry;

cout << "2. Enter FULL PATH to DIR: ";
cin >> entry;

user = entry;

_chdir(user.c_str());

Thanks for your help!!!!!!!

This question has already been answered. Start a new discussion instead.