fuction return in perl
Hi All,
I have a perl script(1.pl) that calls a c function defined in another file sample.c
#!/usr/bin/perl
my $re = 1;
my @s = `/home/PERL_SCRIPTING/Rough/sample pline $re 10`;
print "$_" foreach(@s);
The sample.c is as bwlow:
# include <stdio.h>
int pline(int, int);
main(int argc,char *argv[])
{
int i,j;
printf("Wow Entered main\n");
printf(" %s ", argv[1]);
printf(" %s ", argv[2]);
printf(" %s ", argv[3]);
if(strcmp(argv[1],"pline") == 0)
{
int i,j,k;
i = atoi(argv[2]);
j = atoi(argv[3]);
printf("value of i is %d \n",i);
k = pline(i,j);
printf("%d",k);
}
}
int pline( int x, int y)
{
x = x + 20;
printf("value of x : %d", x);
printf("\n");
return(x);
}
I can call the c function and values are printing. But i need only the value of k to be stored in a variable in the perl script so that i can use it later in teh script.
Is their any solution for this??
Thanks in advance
JS
|