27 lines
515 B
Plaintext
Executable File
27 lines
515 B
Plaintext
Executable File
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
#include <sys/file.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
|
|
int main(int argc, char* argv[]) {
|
|
int fdout = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0600);
|
|
if (fdout == -1) {
|
|
return 1;
|
|
}
|
|
|
|
unsigned short x;
|
|
|
|
while (scanf("%hu", &x) == 1) {
|
|
unsigned char buf[2];
|
|
buf[0] = x >> 8;
|
|
buf[1] = x & 0xff;
|
|
write(fdout, &x, 2);
|
|
}
|
|
|
|
close(fdout);
|
|
|
|
return 0;
|
|
} |