diff options
| author | mo khan <mo@mokhan.ca> | 2015-12-28 21:11:14 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2015-12-28 21:11:14 -0700 |
| commit | 21724e243d16c446c5b918602201a38625246061 (patch) | |
| tree | 427d3cafe1b817cccf20ae84c02e15d8a8def118 | |
implement cat.
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | cat.c | 17 |
2 files changed, 18 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ba077a4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +bin @@ -0,0 +1,17 @@ +#include <stdio.h> + +int main(int argc, char *argv[]) +{ + char *program_name = argv[0]; + char *filename = argv[1]; + FILE *file = fopen(filename, "r"); + + if (file) { + int character; + while( (character = getc(file)) != EOF ) { + putchar(character); + } + fclose(file); + } + return 0; +} |
