> ## Content Index
> Fetch the complete content index at: https://developerinsider.co/llms.txt
> Use this file to discover other available public pages before exploring further.

# Unix cat program -  Programming Puzzles
- URL: https://developerinsider.co/unix-cat-program-programming-puzzles/
- Published: 2016-11-25T18:21:58.000Z
- Updated: 2018-03-29T17:01:03.000Z
- Author: Vineet Choudhary
- Tags: Programming Puzzles, Puzzles

One of the most common standard tasks is to implement a "[cat program](http://esolangs.org/wiki/Cat%5Fprogram?ref=developerinsider.co)": read all of `STDIN` and print it to `STDOUT`. While this is named after the Unix shell utility cat.

#### Task

- 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.

# Solutions

**Jump to [C](#c), [CSharp](#csharp), [JavaScript](#javascript), [PHP](#php) Solution.**  
You can submit your own solution in [comment section](#comments) in same/different programming language. If your solution is better or in different language we'll add here.

## C

```c
#include<stdio.h>
int main()
{
	int i;
	while(i=~getchar())
	putchar(~i);
}

```

## CSharp

```csharp
using System;

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

```

## JavaScript

```js
<html>  
<body>  
    <script>
	for(;;alert(prompt()));
    </script>
</body>  
</html>  

```

## PHP

```php
<? fpassthru(STDIN);

```