c调用lua脚本

适用版本:lua5.1

vc6.0设置:

project->setting:

 

c调用lua脚本_第1张图片

Tools->options:

 

 

c调用lua脚本_第2张图片

 

 

#include <stdio.h> #include "lua.h" #include "lualib.h" #include "lauxlib.h" int main(int argc, char *argv[]) { int s=0; lua_State *L = lua_open(); //load the libs luaL_openlibs(L); //run a lua script here luaL_dofile(L,"foo.lua"); //printf("/n I am done with Lua in C++/n"); lua_close(L); }

 

 

foo.lua:

 

io.write("Please enter your name: ")
name = io.read() -- read input from user
print ("Hi " .. name .. ", enjoy hacking with Lua");

你可能感兴趣的:(c调用lua脚本)