C ++ API Dictionary

Does anyone know an API C ++ dictionary that allows me to search for a word and return a definition?

(I don't mind if this is an online API, and I have to use JSON or XML to parse it)

Edit: Sorry, I meant the dictionary, as in the definitions of words. Not a C ++ map. Sorry for misunderstanding.

+4
source share
4 answers

You can use the aonaware API. (Http://services.aonaware.com/DictService/DictService.asmx). I do not know, however, the cost.

+2
source

Use std::map<string,string> then you can do:

 #include <map> map["apple"] = "A tasty fruit"; map["word"] = "A group of characters that makes sense"; 

and then

 map<char,int>::iterator it; cout << "apple => " << mymap.find("apple")->second << endl; cout << "word => " << mymap.find("word")->second << endl; 

print definitions

+23
source

Try using std::map :

 #include <map> map<string, string> dictionary; // adding dictionary.insert(make_pair("foo", "bar")); // searching map<string, string>::iterator it = dictionary.find("foo"); if(it != dictionary.end()) cout << "Found! " << it->first << " is " << it->second << "\n"; // prints: Found! Foo is bar 
+10
source

I just started to learn C ++. Since I have experience with Python and I am looking for a similar data structure like dictionary in Python. Here is what I found:

 #include <stream> #include <map> using namespace std; int main() { map<string,string> dict; dict["foo"] = "bar"; cout<<dict["foo"]<<"\n"; return 0; } 

Compile and run, you will get:

 bar 
0
source

Source: https://habr.com/ru/post/1343441/


All Articles