lua c api:如何在中间推送一个带空字符的字符串?

lua c api:如何在中间推送一个带空字符的字符串?,第1张

概述通常,我会使用 lua_pushstring(lua_State* L, const char* s); 但是,我要推送字符可能包含空字符.我该如何工作? 使用 lua_pushlstring. void lua_pushlstring (lua_State *L, const char *s, size_t len); Pushes the string pointed to by s wi 通常,我会使用

lua_pushstring(lua_State* L,const char* s);

但是,我要推送的字符串可能包含空字符.我该如何工作?

解决方法 使用 lua_pushlstring.

voID lua_pushlstring (lua_State *L,const char *s,size_t len);

Pushes the string pointed to by s with size len onto the stack. Lua makes (or reuses) an internal copy of the given string,so the memory at s can be freed or reused immediately after the function returns. The string can contain embedded zeros.

总结

以上是内存溢出为你收集整理的lua c api:如何在中间推送一个带空字符的字符串?全部内容,希望文章能够帮你解决lua c api:如何在中间推送一个带空字符的字符串?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1231337.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-06
下一篇2022-06-06

发表评论

登录后才能评论

评论列表(0条)

    保存