init commit
This commit is contained in:
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user