我需要在我的C程序中调用perl例程.perl例程采用以下参数:$a, $b, $c,where $a和$b是整数,$c是一个字符串(可能包含二进制字符).根据perlcall,这里是打电话的方式.
I32 call_sv(SV* sv, I32 flags);
I32 call_pv(char *subname, I32 flags);
I32 call_method(char *methname, I32 flags);
I32 call_argv(char *subname, I32 flags, char **argv);
Run Code Online (Sandbox Code Playgroud)
似乎我只能使用call_argv(...),但有两个问题
希望有一个像这样的功能
I32 call_argv(char *subname, I32 flags, int numOfArgs, SV* a, SV* b, SV *c ...);
Run Code Online (Sandbox Code Playgroud) 当我运行它并输入一个数字时,它只是不停地重复它.例如,如果我放3,它会做3 3 3 3 3但不停止
int main()
{
int current=0, prev=1, prev2=1, fibnum;
cout << "Enter the number of Fibonacci numbers to compute: ";
cin >> fibnum;
if (fibnum <=0)
{
cout << "Error: Enter a positive number: ";
}
while (fibnum > 0){
current = prev + prev2;
prev = prev2;
prev2 = current;
current++;
cout << "," << fibnum;
cout << endl;
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)