diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-12-03 14:57:21 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-12-03 14:57:21 +0100 |
| commit | 7080f89bb2800917bfd9a560046a1ab7505f819e (patch) | |
| tree | a324f9789f5cf9c6cc273989aa46c9c515ccb67e /cpp00/ex01/main.cpp | |
| download | piscine_cpp-7080f89bb2800917bfd9a560046a1ab7505f819e.tar.gz piscine_cpp-7080f89bb2800917bfd9a560046a1ab7505f819e.tar.bz2 piscine_cpp-7080f89bb2800917bfd9a560046a1ab7505f819e.zip | |
Initial commit with cpp00 start
Diffstat (limited to 'cpp00/ex01/main.cpp')
| -rw-r--r-- | cpp00/ex01/main.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/cpp00/ex01/main.cpp b/cpp00/ex01/main.cpp new file mode 100644 index 0000000..051f0e8 --- /dev/null +++ b/cpp00/ex01/main.cpp @@ -0,0 +1,35 @@ +#include <iostream> +#include "PhoneBook.hpp" +#include "Contact.hpp" + +int +main() +{ + std::string user_input; + size_t found_index; + PhoneBook phone_book = PhoneBook(); + + while (true) + { + std::cin >> user_input; + if (user_input == "EXIT") + break; + else if ((found_index = user_input.find("ADD")) == 0) + { + Contact tmp = Contact(user_input.substr(found_index)); + phone_book.add(tmp); + } + else if ((found_index = user_input.find("SEARCH")) == 0) + { + std::string searched = user_input.substr(found_index); + Contact *result = phone_book.search(searched); + if (result == NULL) + std::cout << "Notfound: " << searched << std::endl; + else + std::cout << "Found: " << result->name + << " phone: " << result->phone_str() << std::endl; + + } + } + return 0; +} |
