>>>>> "A" == Andreas Riedl <viisi / chello.at> writes:

A> but i have to embedd ruby in C so i'd like to do this:

 one possible solution is :

pigeon% cat tt.c
#include <ruby.h>
#include <stdio.h>

static VALUE
tt(a)
    VALUE a;
{
    return rb_funcall(a, rb_intern("inspect"), 0, 0);
}

int main()
{
  VALUE vAry,vStr;
  ruby_init();

  vAry = rb_ary_new3(2, INT2FIX(3), INT2FIX(5));

  vStr = rb_funcall(vAry, rb_intern("to_s"), 0, 0);
  printf ("to_s=<%s>\n", STR2CSTR(vStr)); 

  vStr = rb_iterate(tt, vAry, 0, 0);
  printf ("inspect=<%s>\n",STR2CSTR(vStr)); 

  return 0;
}
pigeon% 

pigeon% tt
to_s=<35>
inspect=<[3, 5]>
pigeon% 


Guy Decoux