如何在C中表示类似Python的字典 [英] How to represent a Python-like dictionary in C
本文介绍了如何在C中表示类似Python的字典的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Python中很简单:
In Python it's easy:
x = {}
x['USD'] = "Dollars"
x['CLP'] = "Pesos"
或
y = {'lat': 23.678900, 'lng': 121.451928, 'name': "Sin City"}
我认为大多数这类问题都已解决,因此在哪里可以获取有关C语言中的词典的信息?我不想重新发明轮子.
I think most of these kinds of problems have been solved, so where can I get information about dictionaries in C? I do not want to reinvent the wheel.
如何在C语言中实现字典?
How do I implement a dictionary in C?
推荐答案
它们被称为哈希表或哈希映射.
They are called hash tables or hash maps.
C ++有很多标准配置.
There are lots of std ones for C++.
请参见简单哈希函数
这篇关于如何在C中表示类似Python的字典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文