Next: Acknowledgments Up: 8 Some Examples Previous: 8.9 A CFunction

8.10 Calling Lua Functions from C

This example illustrates how a C function can call the Lua function remove_blanks presented in Section 8.3.

void remove_blanks (char *s)
{
  lua_pushstring(s);  /* prepare parameter */
  lua_call("remove_blanks");  /* call Lua function */
  strcpy(s, lua_getstring(lua_getresult(1)));  /* copy result back to 's' */
}


Next: Acknowledgments Up: 8 Some Examples Previous: 8.9 A CFunction