C 和lua呼叫的簡單問題高分求高手

2021-03-11 06:54:17 字數 964 閱讀 1188

1樓:空雪夢見

#include

#include "lua.hpp"

const char* script =

"index = 1;\n"

"story1 = \n"

";\n"

"function getstory()\n"

"  index = index + 1;\n"

"  return story1[index-1];\n"

"end;";

int main()

2樓:

清除堆疊可以使用 lua_settop() 函式 將指定 index 之後的元素清除。e5a48de588b662616964757a686964616f31333332643838

所以lua_settop(pl,0) 就將整個棧清空了。

void lua_settop (lua_state *l, int index);

accepts any index, or 0, and sets the stack top to this index. if the new top is larger than the old one, then the new elements are filled with nil. if index is 0, then all stack elements are removed.

#include

#include "lua.hpp"

const char* script =

"index = 1;\n"

"story1 = \n"

";\n"

"function getstory()\n"

"  index = index + 1;\n"

"  return story1[index-1];\n"

"end;";

int main()

C函式怎樣呼叫呢,C 函式的定義和呼叫方法

首先,將c 函式分為靜態函式,例項化函式。當c 函式分為靜態函式,呼叫的方式 類.靜態函式名稱 當c 函式分為例項化函式,呼叫的方式 物件.例項化函式名稱 補充一下 在本類中呼叫函式時,不管是那種函式,直接呼叫 函式名稱 即可。最簡單的就是在要呼叫的地方,直接寫函式名稱。建構函式是物件導向的程式設計...

求高手解答一些簡單的C語言題目!(高分懸賞)

1 before globalplusplus it is 1before it is 1 after it is 2 after globalplusplus it is 22 over 3 1 printf input a year scanf d year 2 0 year 4 0 year ...

C呼叫C寫的dll,建構函式出問題

i不應該是這樣嗎?data dwr new data abc efg public data string dbname,string tname 加個public c 呼叫dll的問題。這個問題困擾我很久了!我寫了個一個測試,你看看的 首先是a.dll,我用的是def匯出,你也可以用declspe...