1 | // open() isn't C or C++; it's POSIX
|
2 |
|
3 | #include <fcntl.h> // open
|
4 | #include <stdarg.h> // va_list, etc.
|
5 | #include <stdio.h> // vprintf
|
6 |
|
7 | // #include "dumb_alloc_leaky.h"
|
8 | // #include "mylib.h"
|
9 |
|
10 | void log(const char* fmt, ...) {
|
11 | va_list args;
|
12 | va_start(args, fmt);
|
13 | vprintf(fmt, args);
|
14 | va_end(args);
|
15 | printf("\n");
|
16 | }
|
17 |
|
18 | int main(int argc, char** argv) {
|
19 | log("hello %d", argc);
|
20 |
|
21 | if (argc == 2) {
|
22 | int fd = ::open(argv[1], 0, 0);
|
23 | log("fd = %d", fd);
|
24 | } else {
|
25 | log("expected filename");
|
26 | }
|
27 | return 0;
|
28 | }
|