Copy stdin to stdout: Difference between revisions
add Refal
(→{{header|Ruby}}: Add Ruby) |
Not a robot (talk | contribs) (add Refal) |
||
(9 intermediate revisions by 7 users not shown) | |||
Line 94:
=={{header|Brainf***}}==
<syntaxhighlight lang="brainf***">,[.,]</syntaxhighlight>
=={{header|Binary Lambda Calculus}}==
As explained on https://www.ioccc.org/2012/tromp/hint.html, `cat' is the 4-bit program
<pre>0010</pre>
in bit-wise BLC, or any one of the 16 characters in the ASCII range from space to slash
<pre> !"#$%&'()*+,-./</pre>
in byte-wise BLC.
=={{header|C}}==
Line 99 ⟶ 111:
#include <stdio.h>
int main() {
while (
putchar(c);
}
Line 349 ⟶ 361:
The special string "-" indicates reading from stdin.
<syntaxhighlight lang="frink">print[read["-"]]</syntaxhighlight>
=={{header|FutureBasic}}==
This code uses FileHandles to interact with standard input and standard output. It continuously reads from standard input and writes to standard output until it reaches the end of input.
<syntaxhighlight lang="futurebasic">
// Create file handles for standard input and output
FileHandleRef stdIn = fn FileHandleWithStandardInput
FileHandleRef stdOut = fn FileHandleWithStandardOutput
// Continuously read from standard input…
while (YES)
CFDataRef availableData = fn FileHandleAvailableData( stdIn )
if ( fn DataLength( availableData ) == 0 )
break // End of input
end if
// … and write to standard output
fn FileHandleWriteData( stdOut, availableData, NULL )
wend
</syntaxhighlight>
=={{header|Go}}==
Line 371 ⟶ 401:
}
}</syntaxhighlight>
===io.Copy===
<syntaxhighlight lang="go">
package main
import (
"io"
"os"
)
func main() {
io.Copy(os.Stdout, os.Stdin)
}
</syntaxhighlight>
=={{header|Groovy}}==
Line 405 ⟶ 449:
}
</syntaxhighlight>
Alternative, concise version (Java 9+):
<syntaxhighlight lang="java">
public class CopyStdinToStdout {
public static void main(String[] args) throws java.io.IOException {
System.in.transferTo(System.out);
}
}
</syntaxhighlight>
{{out}}
Output interleaved. Stdin and Stdout are same window.
Line 585 ⟶ 639:
When invoked from a file: Lines are auto-chomped, so need to re-add newlines (hence .say rather than .print)
<syntaxhighlight lang="raku" line>.say for lines</syntaxhighlight>
=={{header|Refal}}==
<syntaxhighlight lang="refal">$ENTRY Go {
, <Card>: {
0 = ;
e.Line = <Go <Prout e.Line>>;
};
};</syntaxhighlight>
=={{header|REXX}}==
Line 707 ⟶ 769:
Bytes are read from stdin and written to stdout until the return key is pressed.
<syntaxhighlight lang="
Stdin.isRaw = true // prevents echoing to the terminal
|