ganesh_mak
01-30-2007, 12:50 PM
Hi,
can somebody give me the example code for this
i need a perl script which uses inlines module for c interface.
in .c file i need a function which gets the list of names in to char names[256][256]
and returns the list of names to the perl @names variable.
i just tried this code but its not working
function getNames() in c returns a ref of the array.so the lookNames() in perl does not return a list of names (array) .
here replace the getNames function in suchway that it returns an array and it should be assigned to the perl array @names;
test.pl
-------------------------------------------------
#! /usr/bin/perl
#use Inline C;
my @name_ref =&lookNames();
__C__
#include <names.c>
char* lookNames()
{
char *x;
x = getNames();
return x;
}
names.c
---------------------------------------
#include <stdio.h>
char* getNames()
{
char names[256][256];
strcpy(names[0],"cf");
strcpy(names[1],"cf1");
strcpy(names[2],"cf2");
return names;
}
can somebody give me the example code for this
i need a perl script which uses inlines module for c interface.
in .c file i need a function which gets the list of names in to char names[256][256]
and returns the list of names to the perl @names variable.
i just tried this code but its not working
function getNames() in c returns a ref of the array.so the lookNames() in perl does not return a list of names (array) .
here replace the getNames function in suchway that it returns an array and it should be assigned to the perl array @names;
test.pl
-------------------------------------------------
#! /usr/bin/perl
#use Inline C;
my @name_ref =&lookNames();
__C__
#include <names.c>
char* lookNames()
{
char *x;
x = getNames();
return x;
}
names.c
---------------------------------------
#include <stdio.h>
char* getNames()
{
char names[256][256];
strcpy(names[0],"cf");
strcpy(names[1],"cf1");
strcpy(names[2],"cf2");
return names;
}