We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 1b3b2f9 + 8fd2149 commit 83caadcCopy full SHA for 83caadc
phonebook.cpp
@@ -0,0 +1,22 @@
1
+#include <iostream>
2
+#include <map>
3
+#include <string>
4
+
5
+int main() {
6
+ std::map<std::string, std::string> phonebook;
7
+ phonebook["Jonny Doe"] = "55145-1234";
8
+ phonebook["Ali Smith"] = "564155-5678";
9
+ phonebook["Hima Johnson"] = "555-1319876";
10
+ std::cout << "Enter a name to search for in the phonebook: ";
11
+ std::string name;
12
+ std::cin.ignore();
13
+ std::getline(std::cin, name);
14
15
+ if (phonebook.find(name) != phonebook.end()) {
16
+ std::cout << name << " : " << phonebook[name] << std::endl;
17
+ } else {
18
+ std::cout << "Contact not found." << std::endl;
19
+ }
20
21
+ return 0;
22
+}
0 commit comments