Last active
May 17, 2018 13:46
-
-
Save mutsune/75bf9d54eae97d7e945d0d9742707147 to your computer and use it in GitHub Desktop.
はじめてのOSコードリーディング リスト10.1 ファイル操作のサンプルコード
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 <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