The mission is to implement a cat
-like program (copy all STDIN to STDOUT).
Rules:
- You may only use standard libraries
- Indentation must be either two spaces or a single tab (in languages which require indentation)
- Scripts must use shebangs
- The result of
cat anything.txt | ./yourprogram | diff anything.txt -
should be nothing and should not be an infinite loop
Go
example (84 bytes)
package main
import (
"os"
"io"
)
func main() {
io.Copy(os.Stdout,os.Stdin)
}
C++
example (78 bytes)
#include<iostream>
using namespace std;
int main() {
cout << cin.rdbuf();
}
Ruby
example (44 bytes)
#!/usr/bin/env ruby
$stdout << $stdin.read
Shortest code (by bytes) wins.
for s in' /\___/\|( o o )|/ * \|\__\_/__/meow| / \| / ___ \| \/___\/'.split('|'):print s
\$\endgroup\$