title: Using C (syscall) to write an integer matrix into a text file?
body: <p>So, I have my matrix, let's say
  <strong>int matC[N][N],</strong>
  which is already filled with integer values.</p>
  
  <p>What I have to do is to save this matrix into a .txt file.
  I've tried this:</p>
  
  <p>1: convert the integers contained in the matrix into a string</p>
  
  <pre><code>char *buffer;
  for (int i = 0 ; i &lt; N ; i++)
  {
      for (int j = 0 ; j &lt; N ; j++)
      {
          snprintf(buffer, sizeof(matC[i][j]), "%d", matC[i][j]);
      }
  }
  </code></pre>
  
  <p>2: write the string in a file (fileC.txt)</p>
  
  <pre><code>int fdC = open("fileC.txt", O_RDWR);
  write(fdC, buffer, sizeof(buffer));
  </code></pre>
  
  <p>I do get something in my fileC.txt, but it's some sort of bunch of unintelegible symbols.
  Thanks in anticipation for any help.</p>