Skip to content
Snippets Groups Projects
Commit e812e557 authored by Christian Dietrich's avatar Christian Dietrich
Browse files

Dec 1 -- The cat on the tip of the iceberg

Article:  https://ibr.cs.tu-bs.de/advent/01-open/
Workload: ~46 source-code lines
parent 8d1fe8ce
No related branches found
Tags template_15
No related merge requests found
cat: cat.c
gcc cat.c -o cat
run: ./cat
./cat cat.c Makefile
strace: ./cat
strace ./cat cat.c Makefile > /dev/null
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
// For cat, we have to iterate over all command-line arguments of
// our process, where argv[0] is our program binary itself ("./cat").
for (int idx = 1; idx < argc; idx++) {
printf("argv[%d] = %s\n", idx, argv[idx]);
}
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment