title: How to create nested Lua tables using the C API
body: <p>I want to create a table like</p>
  
  <pre><code>myTable = {
      [0] = { ["a"] = 4, ["b"] = 2 },
      [1] = { ["a"] = 13, ["b"] = 37 }
  }
  </code></pre>
  
  <p>using the C API?</p>
  
  <p>My current approach is</p>
  
  <pre><code>lua_createtable(L, 0, 2);
  int c = lua_gettop(L);
  lua_pushstring(L, "a");
  lua_pushnumber(L, 4);
  lua_settable(L, c);
  lua_pushstring(L, "b");
  lua_pushnumber(L, 2);
  lua_settable(L, c);
  </code></pre>
  
  <p>to create the inner tables in a loop. Before, this loop, I use</p>
  
  <pre><code>lua_createtable(L, 2, 0);
  int outertable = lua_gettop(L);
  </code></pre>
  
  <p>to create the outer table for 2 numeric slots.</p>
  
  <p>But how can I save the inner tables to the outer table?</p>