Unix cat program - Programming Puzzles

One of the most common standard tasks is to implement a "cat program": read all of STDIN and print it to STDOUT. While this is named after the Unix shell utility cat.


  • You should write a full program which reads the contents of the standard input stream and writes them verbatim to the standard output stream.
  • If and only if your language does not support standard input and/or output streams, you may instead take these terms to mean their closest equivalent in your language (e.g. JavaScript's prompt and and alert).
  • The output should contain exactly the input and nothing else.
  • This also applies to newlines.


Jump to C, CSharp, JavaScript, PHP Solution.
You can submit your own solution in comment section in same/different programming language. If your solution is better or in different language we'll add here.


int main()
	int i;


using System;

namespace testcs
    class Program
        static void Main(string[] args)
            for (;;System.Console.WriteLine(System.Console.In.ReadLine()));




<? fpassthru(STDIN);


Read Community Guidelines
You've successfully subscribed to Developer Insider
Great! Next, complete checkout for full access to Developer Insider
Welcome back! You've successfully signed in
Success! Your account is fully activated, you now have access to all content.