title: Save mysql_fetch_row() output into string array with sprintf(), MySQL C API
body: <p>After hours of unsuccessfully trying to fetch a row from my MySQL DB and saving the output to a string array, I finally decided to come here and ask for help, because I apparently can't solve it myself. This is no homework, I am merely trying to write a simple command line mysql-client that can be integrated into other C projects. As I am not extracting integers from the DB, I can't work with atoi :(</p>
  
  <p>My problem is that I am not able to use <code>sprintf()</code> in order to write the value of <code>row[0]</code> into a <code>field_array[i]</code>, because unlike I thought, <code>row[]</code> is not being incremented on every call to <code>mysql_fetch row()</code>. Actually, when calling this command, <code>row[0]</code> only gets updated with the content of the <code>MYSQL_RES *struct.current_row</code>, in this case <code>MYSQL_RES *headers.current_row</code>. Thus the problem is that I want to be able to call <code>mysql_fetch_row()</code> normally, whilst incrementing the <code>int i</code> for the <code>field_array[i]</code> to be able to successfully <code>sprintf()</code> all values.</p>
  
  <p>Below, the relevant code. If anything is missing, please tell me :)</p>
  
  <p>Used variables:</p>
  
  <pre><code>MYSQL_ROW row;
  MYSQL_RES *headers;
  char field_array[50][100];
  </code></pre>
  
  <p>Part of the code which I don't get to work as intended:</p>
  
  <pre><code>while ((row = mysql_fetch_row(headers)))
   {
       for(int i = 0; i &lt; num_fields; i++)
       {
          printf("%s\n", row[i] ? row[i] : "NULL");
          sprintf(&amp;field_array[i], "%s", row[i]);
       }
   }
  </code></pre>
  
  <p>Please help me, if possible. I am using the Connector/C MySQL API, working on a windows 7 x64 environment with mingw32/GCC (Code::Blocks).</p>
  
  <p>My intention is to write all values into <code>field_array</code> to work with them later on.</p>