diff options
author | Franciszek Malinka <franciszek.malinka@gmail.com> | 2021-05-06 14:28:59 +0200 |
---|---|---|
committer | Franciszek Malinka <franciszek.malinka@gmail.com> | 2021-05-06 14:28:59 +0200 |
commit | f0bd9763ea4be22f0f235c0f3aa6628944a56c7e (patch) | |
tree | c12c047b441bdc520740643e549bd90624601fe8 /Semestr 4/ask/lista9/ropex.c | |
parent | f31c5fa59ee3afafc66bfb53c159eff301b537af (diff) |
Aktualizacja
Diffstat (limited to 'Semestr 4/ask/lista9/ropex.c')
-rw-r--r-- | Semestr 4/ask/lista9/ropex.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Semestr 4/ask/lista9/ropex.c b/Semestr 4/ask/lista9/ropex.c new file mode 100644 index 0000000..dbeae12 --- /dev/null +++ b/Semestr 4/ask/lista9/ropex.c @@ -0,0 +1,31 @@ +#include <stdbool.h> +#include <stdint.h> +#include <stdio.h> + +/* Get string from stdin */ +void readline(FILE *in, char *p) { + int c; + while (true) { + c = fgetc(in); + if (c == EOF || c == '\n') + break; + *p++ = c; + } + *p = '\0'; +} + +void echo(FILE *in) { + char buf[48]; + readline(in, buf); + puts(buf); +} + +int main(int argc, char *argv[]) { + FILE *in = NULL; + if (argc == 2) + in = fopen(argv[1], "rb"); + if (in == NULL) + in = stdin; + echo(in); + return 0; +} |