title: Changing the current directory in Linux using C++
body: <p>I have the following code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;unistd.h&gt;
  
  using namespace std;
  
  int main()
  {
      // Variables
      string sDirectory;
  
      // Ask the user for a directory to move into
      cout &lt;&lt; "Please enter a directory..." &lt;&lt; endl;
      cin &gt;&gt; sDirectory;
      cin.get();
  
      // Navigate to the directory specified by the user
      int chdir(sDirectory);
  
      return 0;
  }
  </code></pre>
  
  <p>The purpose of this code is pretty self explanatory: to set a user specified directory as the current directory. My plan is to carry out operations on the files contained therein. However, when I attempt to compile this code, I receive the following error</p>
  
  <pre><code>error: cannot convert ‘std::string’ to ‘int’ in initialization
  </code></pre>
  
  <p>with reference being made to the line reading <code>int chdir(sDirectory)</code>. I've just started programming and am only now starting to have to find out about platform specific functions, which this one is, so any help on this matter would be most appreciated.</p>