summaryrefslogtreecommitdiffstats
path: root/test.c
blob: ca998dd8ce4bae73bd08c96e0f7f63ff804e24b5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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;
}