title: chdir() in C++ Getting Errors
body: <p>I am trying to run a minimal terminal shell program through a socket on a unix machine. When I use <code>system("cd directory")</code> it doesn't work. So I did a bit of research and came across <code>chdir()</code>, which looked like it would work. When I tried it, though, it gave me errors every single time. Here is my code:</p>
  
  <pre><code>if (chdir(argument) &lt; 0) {
       send(sock, "[*] Directory does not exits!\n", strlen("[*] Directory does not exits!\n"), 0);
  }
  else {
      string argumentString(argument);
      string entireMessage = "[*] New working directory: " + argumentString;
      char entireMessageChar[64];
      int i;
      for (i = 0; entireMessage[i] != '\0'; i++) {
          entireMessageChar[i] = entireMessage[i];
      }
      send(sock, &amp;entireMessage, strlen(entireMessageChar), 0);
  }
  </code></pre>
  
  <p>Could anyone please tell me why <code>chdir()</code> isn't changing directories?
  Thanks.</p>