Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void write_cont_blocks(char *filename)
- {
- struct iovec iov[4];
- struct s1 one;
- struct s2 two;
- int three;
- float four;
- int num_written;
- int fd = open(filename, O_RDONLY);
- if (fd == -1) {
- printf("Error opening file: %s\n", filename);
- printf("Error: %s\n", strerror(errno));
- return;
- }
- // Manipulate the buffers to hold info
- // Build buffers to write
- iov[0].iov_base = &one;
- iov[0].iov_len = sizeof(struct s1);
- iov[1].iov_base = &two;
- iov[1].iov_len = sizeof(struct s2);
- iov[2].iov_base = &three;
- iov[2].iov_len = sizeof(three);
- iov[3].iov_base = &four;
- iov[3].iov_len = sizeof(four);
- num_written = writev(fd, iov, 4);
- if (num_written == -1) {
- printf("Error reading file: %s\n", filename);
- printf("Error: %s\n", strerror(errno));
- }
- close(fd);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement