Thread: How to use associative arrays in C

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    1

    How to use associative arrays in C

    Hi All, Please help me.
    are there any standard functions/libraries to create and manipulate
    associative arrays (hashes) in C on linux/unix ?
    like hashes in perl ...
    If not there is any other way .. do programming like hashes ..

    Regards ,
    Sreenu daram .
    Last edited by sreenu.daram; 11-13-2005 at 02:35 AM.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    No. There are no associative arrays in C. Your best bet is to simulate them using structures with whatever key or name you wish to associate with them.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >If not there is any other way .. do programming like hashes ..
    Well, you could do the same thing that the developers of Perl did and write your own hash table. You could even delve into the Perl source to see how they did it since it's written in C. If anything, you should know how to do it yourself instead of relying on a language feature or library because hash tables are a fundamental data structure.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using Associative Arrays..
    By jewelz in forum C++ Programming
    Replies: 8
    Last Post: 03-23-2009, 04:02 PM
  2. pointers & arrays and realloc!
    By zesty in forum C Programming
    Replies: 14
    Last Post: 01-19-2008, 04:24 PM
  3. Replies: 16
    Last Post: 01-01-2008, 04:07 PM
  4. Need Help With 3 Parallel Arrays Selction Sort
    By slickwilly440 in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2005, 10:47 PM
  5. Crazy memory problem with arrays
    By fusikon in forum C++ Programming
    Replies: 9
    Last Post: 01-15-2003, 09:24 PM