Created
October 3, 2015 01:53
-
-
Save micahalles/ca51a88abbfdbcd4a9d3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/types.h> | |
#include <unistd.h> | |
#include <fcntl.h> | |
int fdin, fdout, retval; | |
char buf[2048]; | |
ssize_t nread, nwrote; | |
fdin = open("readfile", O_RDONLY); | |
fdout = open("writefile", O_CREAT | O_WRONLY, 0644); | |
nread = read(fdin, buf, 2048); | |
nwrote = write(fdout, buf, (size_t)nread); | |
retval = close(fdin); | |
retval = close(fdout); | |
// (calls can fail!!, read man pages and /usr/include/fcntl.h, also think | |
// of copying a file larger than 2048 bytes - try buffer at a time till done!) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment