# Printing the array values in c

**URL:** <https://www.ruby-forum.com/t/printing-the-array-values-in-c/120641>\
**Category:** Ruby\
**Created:** [November 19, 2007, 2:22pm UTC](https://www.ruby-forum.com/t/printing-the-array-values-in-c/120641 "2007-11-19T14:22:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [November 19, 2007, 2:22pm UTC](https://www.ruby-forum.com/t/printing-the-array-values-in-c/120641/1 "2007-11-19T14:22:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [November 19, 2007, 2:48pm UTC](https://www.ruby-forum.com/t/printing-the-array-values-in-c/120641/2 "2007-11-19T14:48:41Z")

</div>

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.
