This is an example of LUA programming, a simple record.
#include <stdio.h> #include <lua5.2/lua.h> #include <lua5.2/lauxlib.h>static void Stackdump (Lua_ State *l) {int i; int top = lua_gettop (L); for (i = 1; I <= top; i++) {int t = Lua_type (L, i); Switch (t) {case lua_tstring:printf ("'%s '", lua_tostring (L, i)); Break Case lua_tboolean:printf (Lua_toboolean (L, i)? "True": "false"); Break Case lua_tnumber:printf ("%g", Lua_tonumber (L, i)); Break default:printf ("%s", Lua_typename (L, t)); Break } printf (""); } printf ("\ n");} int main (void) {Lua_state *l = Lual_newstate (); Lua_pushboolean (L, 1); Lua_pushnumber (L, 10); Lua_pushnil (L); Lua_pushstring (L, "Vonzhou"); Stackdump (L); Dump the Stack lua_pushvalue (L,-4);//Push the value of the index to the stack stackdump (l); Lua_replace (L, 3); Pop a value and replace the index ' s stackdump (L); Lua_settop (L, 6); Set the top index, fill ' nil ' stackdump (L); Lua_remove (L,-3); Stackdump (L); Lua_settop (L,-5); Stackdump (L); Lua_close (L); return 0;}
Operation Result:
simply draw a:
C API example for stack operations in Lua