[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

printing the array values in c

Saladin Mundi

11/19/2007 1:21:00 PM

hey.

how is it possible to print out an array (T_ARRAY) in a C-method?

example

I want to get the instance methods via the corresponding c method. the =
method returns T_ARRAY.
VALUE es =3D rb_class_instance_methods(1, args, CLASS_OF(targetcl));

is there something like:=20
for(int i =3D 0; i<RARRAY_LEN(es); i++)
{
printf("content of array element %s",es[i]);=20
}
?? :)
I know that the content of the array element is a (ruby) string.

thx for your help in advance
1 Answer

Tim Hunter

11/19/2007 1:49:00 PM

0

unknown wrote:
> hey.
>
> how is it possible to print out an array (T_ARRAY) in a C-method?
>
> example
>
> I want to get the instance methods via the corresponding c method. the
> method returns T_ARRAY.
> VALUE es = rb_class_instance_methods(1, args, CLASS_OF(targetcl));
>
> is there something like:
> for(int i = 0; i<RARRAY_LEN(es); i++)
> {
> printf("content of array element %s",es[i]);
> }
> ?? :)
> I know that the content of the array element is a (ruby) string.
>
> thx for your help in advance

rb_ary_entry(n) returns the VALUE at index n.
StringValuePtr(obj) returns a pointer to the C string in a String
object.
--
Posted via http://www.ruby-....