字典用来存储键值对。 相关结构体定义:typedefstructAVDictionaryEntry{charkey;charvalue;}AVDictionaryEntry;structAVDictionary{intcount;AVDictionaryEntryelems;};typedefstructAVDictionaryAVDictionary; 1、创建一个字典AVDictionarydNULL;createanemptydictionary NULL可以作为一个空字典,在任何需要指向AVDictionary指针的地方使用。 2、添加一个键值对avdictset(d,foo,bar,0);addanentry 3、遍历字典AVDictionaryEntrytNULL;while((tavdictiterate(d,t))){。。。。iterateoverallentriesind} 4、获取某个键值对AVDictionaryEntrytavdictget(d,foo,NULL,AVDICTMATCHCASE); 5、释放字典以及包含的内容avdictfree(d); 6、例子includestdio。hincludelibavutildict。hintmain(){AVDictionarydNULL;avdictset(d,name,clark,0);avdictset(d,age,18,0);avdictset(d,sex,man,0);avdictset(d,job,engineer,0);constAVDictionaryEntrytNULL;while((tavdictiterate(d,t))){printf(ss,tkey,tvalue);}tavdictget(d,job,NULL,AVDICTMATCHCASE);avdictfree(d);return0;} 输出: 演示例子打印