#include #include #include #include #include #include struct test{ char b1; char b2; char b3; }; int main(void){ char buf[9]; int fd_r; //struct test *s_test = malloc(sizeof(struct test)); struct test *s_test = NULL; memset(buf, 0, 9); if ((fd_r = open("test.txt", O_RDONLY)) == -1){ exit(-1); } read(fd_r, buf, 9); for (int i = 0; i < 9; i++){ printf("%c", buf[i]); } printf("\n"); s_test = (struct test*)buf + 2; printf("%c %c %c\n", s_test->b1, s_test->b2, s_test->b3); close(fd_r); //free(s_test); }