title: changing the directory from inside a c program under windows using system command
body: <p>I have a problem where I have to run a command prompt command from inside a C program. Here is what I did</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  
  
  int main(){
  
  
  
  system("cd \Users");
  system("Dir");
  
  }
  </code></pre>
  
  <p>The problem is I want to cd into Users first and then execute the command Dir where as currently the program outputs that it cant find the path specified and the Dir is executed in the parent process directory i-e where the program source file is located. </p>
  
  <p>The actual task I want to do is just want to run a java file from a particular directory from inside a C program. that java file is in C:\Users\Abdullah\pro . My C program's parent directory is C:\Users\Cprog. Please advise on how may I do this</p>