Skip to content

Instantly share code, notes, and snippets.

@mutsune
Created December 17, 2018 07:50
Show Gist options
  • Save mutsune/ec206b758422bb6f5395c1270bd6f196 to your computer and use it in GitHub Desktop.
Save mutsune/ec206b758422bb6f5395c1270bd6f196 to your computer and use it in GitHub Desktop.
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main() {
int fd;
char buf[2];
fd = open("filename.txt", 2);
read(fd, buf, 2);
buf[0] = 'a';
buf[1] = 'b';
lseek(fd, 0, 0);
write(fd, buf, 2);
close(fd);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment