Skip to content

Instantly share code, notes, and snippets.

@ajpen
Last active August 29, 2015 14:21
Show Gist options
  • Save ajpen/3fb81274ae024634d6f1 to your computer and use it in GitHub Desktop.
Save ajpen/3fb81274ae024634d6f1 to your computer and use it in GitHub Desktop.
File copying program
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char* argv[]){
char buffer; //number of bits copied at once
FILE* source = fopen(argv[1],"r");
FILE* dest = fopen(argv[2],"w");
while((fread(&buffer, 1, 1, source)) > 0) {
fwrite(&buffer, 1, 1, dest);
}
fclose(source);
fclose(dest);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment