Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <limits.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <unistd.h>
- int main(int argc, char **argv) {
- int file = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0600);
- unsigned short val;
- unsigned char buf[sizeof(val)];
- while (scanf("%hu", &val) == 1) {
- buf[0] = val >> CHAR_BIT;
- buf[1] = val;
- write(file, buf, sizeof(buf));
- }
- close(file);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement