#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
int main() {
lua_State *L = lua_open();
luaopen_base(L);
luaL_loadstring(L, "function f() print(0) end");
lua_call(L, 0, 0);
lua_getglobal(L, "f");
if(lua_pcall(L, 0, 0, 0) != 0) {
printf("error: %s\n", lua_tostring(L, -1));
}
lua_pop(L, 1);
lua_close(L);
}
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
int main() {
lua_State *L = lua_open();
luaopen_base(L);
lua_getglobal(L, "print");
lua_pushstring(L, "hello lua.");
if(lua_pcall(L, 1, 0, 0) != 0) {
printf("error: %s\n", lua_tostring(L, -1));
}
lua_pop(L, 1);
lua_close(L);
}