Read and write in c++
<p>I am trying to use the system calls read() and write(). The following program creates a file and writes some data into it. Here is the code..</p>

<pre><code>int main()
{
    int fd;
        open("student",O_CREAT,(mode_t)0600);

    fd=open("student",O_WRONLY);
    char data[128]="Hi nikhil, How are u?";

    write(fd,data,128);

}
</code></pre>

<p>Upon the execution of the above program i got a file with name student created with size as 128 bytes.</p>

<pre><code>int main()
{
    int fd=open("student",O_WRONLY);
    char data[128];
    read(fd,data,128);
    cout&lt;&lt;(char*)data&lt;&lt;endl;
}
</code></pre>

<p>But the output i get is junk characters....why is this so?</p>

<p>I wrote a small read program to read data from the file. Her is the code.</p>

<p>But the output </p>
