title: write system call in C, how to print integer value to file
body: <p>I'm tring to write an variable to a file, but I keep getting syntax errors or it doesn't prints it to the file.</p>
  
  <p>I have info.uptime, and I want to print it to "file.txt", so I tried:</p>
  
  <pre><code>int fd = open("file.txt", O_WRONLY);
  write(fd, info.uptime, length(info.uptime));
  </code></pre>
  
  <p>The length fucntion is function that I created to see the length of the number.
  At the file the numbers are gone, so I tried:</p>
  
  <pre><code>int fd = open("file.txt", O_WRONLY);
  write(fd,("%lu" ,info.uptime), length(info.uptime));
  </code></pre>
  
  <p>Now it gives me syntax error too many arguments.
  How should I do it?</p>
  
  <p><em>it's on ubuntu</em></p>
  
  <p>EDIT: I can ONLY use:</p>
  
  <pre><code>#include &lt;unistd.h&gt;
  #include &lt;sys/sysinfo.h&gt;
  #include &lt;sys/syscall.h&gt;
  #include "helper.h"
  </code></pre>
  
  <p>EDIT2:</p>
  
  <pre><code>int length(int n)
  {
          int i;
      for (i=0;n&gt;=1;i++)
      {
          n = n/10;
      }
      return i;
  }
  </code></pre>