I have the following code:
#include <iostream>
#include <string>
#include <unistd.h>
using namespace std;
int main()
{
string sDirectory;
cout << "Please enter a directory..." << endl;
cin >> sDirectory;
cin.get();
int chdir(sDirectory);
return 0;
}
The purpose of this code is pretty clear: set the directory specified by the user as the current directory. My plan is to perform operations on the files contained in it. However, when I try to compile this code, I get the following error:
error: cannot convert βstd::stringβ to βintβ in initialization
with reference to reading the line int chdir(sDirectory). I just started programming, and now I'm just starting to learn about the platform-specific functions that are in this, so any help on this would be most appreciated.
source
share