title: How to copy a file into a directory with the rsync or something else?
body: <p>In this code, I am trying to copy the <code>file.txt</code> to the directory named <code>folder</code> but when I run the code, it gives me the following error. I searched online but didn't find a solution.</p>
  <p><strong>Error</strong></p>
  <pre><code>rsync: change_dir &quot;/home/runner/TestC1/text&quot; failed: Not a directory (20)
  rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1196) [sender=3.1.2]
  </code></pre>
  <p><strong>Code</strong></p>
  <pre><code>char *transfer(char *f1, char *f2){
      char cmd[500];
      snprintf(cmd, 500, &quot;rsync -a %s/ %s&quot;, f1, f2);
      system(cmd);    
      return 0;
  }
  
  int main(){
    transfer(&quot;/home/runner/TestC1/file.txt&quot;, &quot;/home/runner/TestC1/folder&quot;);
    return 0;
  }
  </code></pre>