public/subjects/cat/README.md

35 lines
1.9 KiB
Markdown
Raw Permalink Normal View History

2019-06-18 02:16:45 +00:00
## cat
2019-04-18 12:50:04 +00:00
### Instructions
2019-04-18 12:50:04 +00:00
2020-05-17 15:59:16 +00:00
Write a program that behaves like a simplified `cat` command.
2019-04-18 12:50:04 +00:00
2020-05-17 15:59:16 +00:00
- The options do not have to be handled.
2019-04-18 12:50:04 +00:00
2020-05-17 18:44:25 +00:00
- If the program is called without arguments it should take the standard input (stdin) and print it back on the standard output (stdout).
2019-04-18 12:50:04 +00:00
```console
$ echo '"Programming is a skill best acquired by practice and example rather than from books" by Alan Turing' > quest8.txt
$ cat <<EOF> quest8T.txt
2020-05-17 15:59:16 +00:00
"Alan Mathison Turing was an English mathematician, computer scientist, logician, cryptanalyst. Turing was highly influential in the development of theoretical computer science, providing a formalisation of the concepts of algorithm and computation with the Turing machine, which can be considered a model of a general-purpose computer. Turing is widely considered to be the father of theoretical computer science and artificial intelligence."
EOF
$ go run . abc
2022-03-25 14:08:32 +00:00
ERROR: open abc: no such file or directory
exit status 1
$ go run . quest8.txt
2019-04-18 12:50:04 +00:00
"Programming is a skill best acquired by pratice and example rather than from books" by Alan Turing
$ go run . quest8.txt abc
2020-05-17 18:44:25 +00:00
"Programming is a skill best acquired by pratice and example rather than from books" by Alan Turing
ERROR: open abc: No such file or directory
$ cat quest8.txt | ./cat
2020-05-17 15:59:16 +00:00
"Programming is a skill best acquired by pratice and example rather than from books" by Alan Turing
$ go run .
2019-11-26 09:48:22 +00:00
Hello
2019-11-26 22:53:19 +00:00
Hello
^C
$ go run . quest8.txt quest8T.txt
2019-04-18 12:50:04 +00:00
"Programming is a skill best acquired by pratice and example rather than from books" by Alan Turing
"Alan Mathison Turing was an English mathematician, computer scientist, logician, cryptanalyst. Turing was highly influential in the development of theoretical computer science, providing a formalisation of the concepts of algorithm and computation with the Turing machine, which can be considered a model of a general-purpose computer. Turing is widely considered to be the father of theoretical computer science and artificial intelligence."
$
2019-04-18 12:50:04 +00:00
```