title: How can I create database tables using structures
body: <p>I am trying to create and store databases using c interface. I have a structure table that contains some variables and datatypes. How would I convert them into database tables. The details are mentioned below. In, database.c file, I initialized createTable function and Folder_table structure that contains the constraints and data types and I have a function to connect to the database in firebird. Once I read this structure, I would like to know how can I convert this structure into table and store it in the database. (Is there something I can do with sprintf?)</p>
  
  <pre><code>**database.c:**
  #include "/Library/Frameworks/Firebird.framework/Versions/A/Headers/ibase.h"
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  void* CreateTable(char *tableName, uint rows)
  {
      int error   = 0;
      void *table;
  
      //// Allocate table
      table = Allocate(GetTableSize(tableName)*rows);
  
      //// List table pointers
      for(uint rowNumber=0; rowNumber &lt; rows; rowNumber++)
      {
          //// Add code to Connect linked list row pointers
      }
  
      return error;
  }
  
  typedef struct Folder_Table       // Table type name gets "_Table" added to the SQLite name
  {
      //// Fields                   // Comments are added to seperate the fields, Relationships, and metadata
      int     folderID;             // Fields are added as elements of the type and length listed in SQLite
      float   field1;
      int     field2;
      float   field3;
      char    field4[40];           // string length '40' is queried from SQLite settings for field
  
  } Folder_Table;
  int SQLOpen(void)
  {
      char                logInData [256];
      short               bufferLength;
      sprintf(logInData, "%c%c%c%c%c%c%s%c%c%s",      isc_dpb_version1,
              isc_dpb_num_buffers,
              1,
              90,
              isc_dpb_user_name,
              strlen("SYSDBA"),
              "SYSDBA",
              isc_dpb_password,
              strlen("masterkey"),
              "masterkey");
  
      bufferLength = strlen(logInData);
      if (isc_attach_database(status_vector, strlen(DATABASE_PATH), DATABASE_PATH, &amp;DatabaseHandle,bufferLength, logInData))
      {
  
          isc_print_status(status_vector);
  
      }
  
  
      return 0;
  
  }
  **main.c:**
  #include &lt;stdio.h&gt;
  #include&lt;string.h&gt;
  #include "/Library/Frameworks/Firebird.framework/Versions/A/Headers/ibase.h"
  
  char  Query[] = "SELECT * FROM Folder_Table WHERE ID = 3";
  int main(int argc, char *argv[])
  {
      SQLOpen();
      Folder_Table *myTable;
      myTable = CreateTable("Folder_Table", ONE_ROW);
  
  }
  </code></pre>