Write to stdout and read from stdin in C
<p>I am writing two c files that one is to write(by stdout) and another is read(by stdin).</p>

<p>But the read code is always hangs with read(), I have tried fread function but useless.</p>

<p>Can someone give advice?</p>

<p>Write example:</p>

<pre><code>int main() {
    char *a_string="Hello";
    write(fileno(stdout), a_string, strlen(a_string)+1);

    return 0; 
}
</code></pre>

<p>Read example:</p>

<pre><code>int main() {
    char buffer[100];
    read(fileno(stdin), buffer, 100-1);
    printf("buffer=%s\n", buffer);

    return 0;
}
</code></pre>