How to write to a file using open() and printf()?
<p>I am opening a file with open(), and need to print to that file using printf with no output to the console. How do I do this? I can successfully create the file, and printf to the console, but that is not correct. </p>

<pre><code>int main(int argc, char *argv[]) {
    int fd;
    char *name = "helloworld";
    fd = open(name, O_CREAT);

    char *hi = "Hello World";
    printf("%s\n", hi);

    close(fd);
    exit(0);
}
</code></pre>

<p>I need the program to have no output to the console, but if I look at the file <code>helloworld</code>, it should have "Hello World" written inside. Such as: </p>

<pre><code>prompt&gt; ./hello
prompt&gt; more helloworld
   Hello World
</code></pre>