title: C++ / C: Move Directory to Another Location
body: <p>I want to move the contents of one directory to another. I specify the source and destination directories via command line arguments. Here's the code:</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  
  void move_dir(FILE *src, FILE *dest) {
      int c = getc(src);
      while(getc(src)!=EOF) {
          putc(c,dest);
      }
  }
  
  int main(int argc, char* argv[])
  {
      FILE *src=fopen(argv[1]);
      FILE *dest=fopen(argv[2]);
      while(--argc&gt;0) {
          if(src!=NULL &amp;&amp; dest!=NULL) {
              move_dir(src,dest);
          }
      }
      fclose(src);
      fclose(dest);
      return 0;
  }
  </code></pre>
  
  <p>For example:</p>
  
  <pre><code>./a.out /Folder1/Folder2/Source /Folder1
  </code></pre>
  
  <p>This will move the folder called Source inside of Folder1. However when I execute this code it doesn't work. It compiles just fine with g++ and no errors when running but it just doesn't move anything at all. Any ideas on what could be wrong?</p>