Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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 studying the Monastery: (17)
As of 2015-07-01 17:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (14 votes), past polls