c++ - 将字符串向量推送到lua
问题描述
我试图推动字符串向量。但不知何故它返回 nil
它是我的代码:
static int Lua_Extract(lua_State* L) {
std::vector<std::string> foundedEvents;
foundedEvents.push_back("xx");
lua_createtable(L, foundedEvents.size(), 0);
int newTable = lua_gettop(L);
for (size_t i = 1; i < foundedEvents.size(); i++)
{
lua_pushstring(L, foundedEvents[i].c_str());
lua_rawseti(L, newTable, i);
}
return 1;
}
解决方案
推荐阅读
- python - python,json类型写入-我如何在字典值上使用\ n?
- macos - 如何查找特定 git 子命令的手册页
- javascript - 聊天系统 - 如何在这段代码中发送数据 - php,ajax,js
- ios - 在长时间运行的进程的后台处理期间防止 EXC_BAD_ACCESS
- aws-codecommit - 向 CodeCommit 发出请求时出错:无法检索
- javascript - 将数据从 swift 发布到 node.js
- python - 在python中将二进制转换回ascii
- c# - 如何防止HttpClient在发送请求时产生新行?
- swift - 如何在不使用 seague 和 storyboard 的情况下将数据从一个视图控制器传递到另一个视图控制器
- api - API 需要验证码是设计缺陷吗?