diff options
author | syn <isaqtm@gmail.com> | 2020-01-31 09:02:55 +0300 |
---|---|---|
committer | syn <isaqtm@gmail.com> | 2020-01-31 09:02:55 +0300 |
commit | c21e867c6b272fb6722c46aa0a06d63611d0a373 (patch) | |
tree | c2250fd3f42d195e263ef2b70d57bbef178ae7cd /test.c | |
parent | 6662cea6b2572cd70a60aadfb28312e2bbef6ecc (diff) | |
download | sad-c21e867c6b272fb6722c46aa0a06d63611d0a373.tar.gz |
Finished echo with private data
Diffstat (limited to 'test.c')
-rw-r--r-- | test.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -0,0 +1,15 @@ +#include <unistd.h> +#include <stdio.h> +#include <fcntl.h> + +int main() { + int fd = open("dev", O_RDWR); + const char buf[] = "Some string"; + printf("wrote %d bytes\n", write(fd, buf, sizeof(buf))); + char retbuf[256]; + int bytes_read = read(fd, retbuf, sizeof(retbuf)); + printf("read %d bytes\n", bytes_read); + retbuf[bytes_read] = 0; + printf("ret: '%s'\n", retbuf); + return 0; +}
\ No newline at end of file |