Na primer, za upisivanje i citanje strukture:
Code:
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
typedef struct {
int a, b, c;
} struktura_neka;
int main() {
struktura_neka test0, test1;
int fd;
fd = open("/tmp/test_fajl", O_CREAT | O_RDWR, S_IRUSR | S_IRUSR);
test0.a = 2;
test0.b = 4;
test0.c = 8;
write(fd, &test0, sizeof (test0));
lseek(fd, 0, SEEK_SET);
read(fd, &test1, sizeof (test0));
printf("%d %d %d\n", test1.a, test1.b, test1.c);
close(fd);
unlink("/tmp/test_fajl");
return 0;
}