Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

monarch's scratchpad

by monarch (Priest)
on May 28, 2005 at 06:21 UTC ( #461293=scratchpad: print w/ replies, xml ) Need Help??

#include "apr.h" #include "apr_hash.h" #include "apr_pools.h" #include <stdio.h> int main( void ) { apr_pool_t *pool; apr_hash_t *myhash; apr_hash_index_t *index; long int *mynum; apr_initialize(); apr_pool_create( &pool, NULL ); myhash = apr_hash_make( pool ); mynum = apr_palloc( pool, sizeof(long int) ); *mynum = 10; apr_hash_set( myhash, mynum, sizeof(long int), "ten" ); mynum = apr_palloc( pool, sizeof(long int) ); *mynum = 23; apr_hash_set( myhash, mynum, sizeof(long int), "twenty-three" ); mynum = apr_palloc( pool, sizeof(long int) ); *mynum = 13; apr_hash_set( myhash, mynum, sizeof(long int), "thirteen" ); for ( index = apr_hash_first( pool, myhash ); index; index = apr_hash_next( index ) ) { long int *key; apr_ssize_t len; char *val; apr_hash_this( index, &key, &len, &val ); if ( len != sizeof(*key) ) { printf( "Returned key length was %d\n", (int)len ); continue; } printf( " retrieved number %ld = \"%s\"\n", (long int)*key, val ); } return( 0 ); }

Outputs:

retrieved number 23 = "twenty-three" retrieved number 10 = "ten" retrieved number 13 = "thirteen"

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (12)
As of 2015-09-02 13:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred temperature scale is:










    Results (83 votes), past polls