lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I'm not sure why that pasted with a #include in that if statement. Here's the correct version:

#include <stdio.h>
#include <string.h>
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>

int main(int argc, char *argv[])
  char buff[256];
  int error;
  lua_State *L;
  L = lua_open();

  while(fgets(buff, sizeof(buff), stdin) != NULL)
    error = luaL_loadbuffer(L, buff, strlen(buff), "line") ||
        lua_pcall(L, 0, 0, 0);
    if (error)
      fprintf(stderr, "%s", lua_tostring(L, -1));
      lua_pop(L, 1);

  return 0;


-Patrick Donnelly

"One of the lessons of history is that nothing is often a good thing to do and always a clever thing to say."

-Will Durant