Skip to content

Commit 83caadc

Browse files
Merge pull request #135 from sunnyshahabuddin0/patch-1
Create phonebook.cpp
2 parents 1b3b2f9 + 8fd2149 commit 83caadc

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

phonebook.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)