title: C programming: write() integers to a text file
body: <p>I m trying to write a couple of integers on a text file using write() sys call, but insead of numbers i got strange symbols (<strong>00\00\00\00\00\00</strong>).</p>
  
  <p>Gedit is telling me that there is an issue with encoding and that the file is not in UTF-8. I m compiling with gcc which should has the UTF-8 codec set by default. I solved the '\00' by changing the sizeof(i) with 1 but i cant resolve the numbers.</p>
  
  <pre><code>int main(int argc, char const *argv[]) {
     int fd=open("test.txt", O_RDWR | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR);
     int i = 2;
     write(fd, &amp;i, sizeof(i)); }
  </code></pre>