Results 1 to 3 of 3
If I have such an array in PHP
Code:
<?php
$s = array(
'go' => array('walk', 'travel', 'perambulate'),
'get' => array('take', 'swipe', 'yoink', 'pocket')
);
?>
How to I replicate ...
- 08-07-2011 #1
Convert simple PHP array to c
If I have such an array in PHP
How to I replicate that in c?Code:<?php $s = array( 'go' => array('walk', 'travel', 'perambulate'), 'get' => array('take', 'swipe', 'yoink', 'pocket') ); ?>
I seem to have it a brick wall with this one
If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)
My new blog. It's probably not as good as I think it is.
- 08-07-2011 #2
So, of course, this is not what is called in C an array: it is a dictionary or a hash map. It maps strings to arrays of strings.
So first, you need access to a hash map implementation. It's not incredibly difficult to implement your own, but it is a bit of a pain. I have used uthash before on many occasions:
uthash User Guide
They also provide a linked list implementation (utlist) that may be a good replacement for your string arrays if they are better represented as linked lists.
Anyway, hopefully that documentation makes sense to you. Let me know if I can help with anything else.DISTRO=Arch
Registered Linux User #388732
- 08-07-2011 #3
Well, that means going back into K&R as I haven't met structs yet. I was wondering when I'd need to do some more reading.
Thanks.If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)
My new blog. It's probably not as good as I think it is.


Reply With Quote