Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我开始使用 C 和 mruby。我有一个使用 mrubymrb_load_string函数调用 Ruby 函数的程序。我想将参数从 C 函数传递给 Ruby 函数。我怎样才能做到这一点?
mrb_load_string
void on_key(const char *key) { mrb_load_string(mrb, "input_received()"); // how do I pass key as an argument? }
如果您的 ruby 函数将字符串作为参数输入,则:
void on_key(const char *key) { char arg[64]; sprintf(arg,"input_received(\"%s\")",key);//Embed key as an argument to the function mrb_load_string(mrb, arg); }
应该做你想做的。