RElicAnalysis/tests/test_buffer.c
2026-04-29 13:56:33 +02:00

37 lines
670 B
C

#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
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);
}