C alternative to fputs()/fgets() with open()
<p>I'm learning about kernel modules communicating with user level programs and originally was opening a file with</p>

<pre><code>FILE *pFile = fopen(...)
</code></pre>

<p>and writing to it with </p>

<pre><code>char *str = malloc(10);
fputs(str, pFile);
</code></pre>

<p>However now I need to use functionality in <code>#include &lt;fcntl.h&gt;</code> to attempt some asynchronous notifications and the example I have instead uses </p>

<pre><code>int pFile;
pFile = open("/dev/mymodule", O_RDWR);
</code></pre>

<p>I think that I can no longer use <code>fputs()</code> or <code>fgets()</code> because it requires a <code>FILE *ptr</code> and I have an <code>int</code> instead now. I think I'm supposed to use <code>write()</code> and <code>read()</code> instead. </p>

<p>Is this how it would work?</p>

<pre><code>write(pFile, str,  sizeof(str));

char line[256];
    while (read(pFile, line, 256) != NULL) {
            printf("%s", line);
        }
</code></pre>