0

I need to create a Map data type in C, just to reduce the complexity order of an algorithm.

I am trying to do something like this:

{
   "emma": "watson",
   "raul": "boome",
}

where the "key" is the name, and the "value" the surname.

Then, I have to be able to access it easily, in O(1), like this:

// Pseudocode
printf("%s", map.emma);

Any ideas? Thank you.

Raul
  • 2,673
  • 1
  • 15
  • 52
  • 1
    Does this answer your question? [Implementing a HashMap in C](https://stackoverflow.com/questions/838404/implementing-a-hashmap-in-c). You have a statically typed "generic" macro-based implementation in [klib here](https://attractivechaos.wordpress.com/2009/09/29/khash-h/). – vgru Nov 08 '20 at 15:49
  • [A newer version might be on GitHub](https://github.com/attractivechaos/klib). – vgru Nov 08 '20 at 16:07

0 Answers0