#include #include #include #include #include struct dessert { char name[16]; int calories; int rating; }; int main(){ int fd = open("desserts.dst", O_RDWR | O_CREAT | O_TRUNC, 0644); lseek(fd, 1024, SEEK_SET); write(fd, " ", 1); void *file_region = mmap(0, 1024, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); struct dessert d = {"Cupcake", 150, 3}; memcpy(file_region, &d, sizeof(d)); // More direct struct dessert *dessert_list = file_region; for(int i = 1; i < 4; i++){ printf("Enter the name: "); scanf("%s", &(dessert_list[i].name) ); printf("Enter the number of calories: "); scanf("%d", &(dessert_list[i].calories)); printf("Enter a rating: "); scanf("%d", &(dessert_list[i].rating)); } munmap(file_region, 1024); close(fd); return 0; }