# How to use st\_table by oneself?

**URL:** <https://www.ruby-forum.com/t/how-to-use-st-table-by-oneself/150168>\
**Category:** Ruby\
**Created:** [October 5, 2008, 6:05am UTC](https://www.ruby-forum.com/t/how-to-use-st-table-by-oneself/150168 "2008-10-05T06:05:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gpygood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/67e7ee/32.png) [@gpygood](https://www.ruby-forum.com/u/gpygood)\
**Post date:** [October 5, 2008, 6:05am UTC](https://www.ruby-forum.com/t/how-to-use-st-table-by-oneself/150168/1 "2008-10-05T06:05:11Z")

</div>

[http://www.ruby-doc.org/doxygen/1.8.4/st\_8c.html](http://www.ruby-doc.org/doxygen/1.8.4/st_8c.html)  
Is there some tutorials or examples about it?thanks

---

<div class="post-metadata">

**Author:** ![gpygood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/67e7ee/32.png) [@gpygood](https://www.ruby-forum.com/u/gpygood)\
**Post date:** [October 5, 2008, 9:33pm UTC](https://www.ruby-forum.com/t/how-to-use-st-table-by-oneself/150168/2 "2008-10-05T21:33:36Z")

</div>

gz zz wrote:

> [http://www.ruby-doc.org/doxygen/1.8.4/st\_8c.html](http://www.ruby-doc.org/doxygen/1.8.4/st_8c.html)  
> Is there some tutorials or examples about it?thanks

hash.c in the ruby source might help. Also, the Ruby Hacking Guide has  
some info:

[http://rhg.rubyforge.org/chapter03.html](http://rhg.rubyforge.org/chapter03.html)

---

<div class="post-metadata">

**Author:** ![gpygood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/67e7ee/32.png) [@gpygood](https://www.ruby-forum.com/u/gpygood)\
**Post date:** [October 6, 2008, 3:25am UTC](https://www.ruby-forum.com/t/how-to-use-st-table-by-oneself/150168/3 "2008-10-06T03:25:14Z")

</div>

Joel VanderWerf wrote:

> gz zz wrote:
> 
> > [http://www.ruby-doc.org/doxygen/1.8.4/st\_8c.html](http://www.ruby-doc.org/doxygen/1.8.4/st_8c.html)  
> > Is there some tutorials or examples about it?thanks
> 
> hash.c in the ruby source might help. Also, the Ruby Hacking Guide has  
> some info:
> 
> [http://rhg.rubyforge.org/chapter03.html](http://rhg.rubyforge.org/chapter03.html)  
> oh,thank you!  
> My “hello world” with st\_table:

#include \<stdio.h\>  
#include \<stdlib.h\>  
#include “st.c”  
int main(int argc, char \*argv[])  
{  
st\_table \*tbl=st\_init\_numtable();

st\_insert(tbl,1,100);  
char \*hello = “hello world”;  
st\_insert(tbl,2,(st\_data\_t)hello);  
st\_data\_t ret;  
if(st\_lookup(tbl,1,&ret)){  
printf(“%d\n”,ret);  
}

if(st\_lookup(tbl,2,&ret)){  
printf(“%s\n”,ret);  
}

st\_free\_table(tbl);  
system(“PAUSE”);  
return 0;  
}
