aboutsummaryrefslogtreecommitdiff
path: root/hw6
diff options
context:
space:
mode:
authorraquelc <[email protected]>2024-03-14 14:12:22 -0700
committerraquelc <[email protected]>2024-03-14 14:12:22 -0700
commitfc6a16dd4adfb6a5daf0a291e85e571c6b5866cb (patch)
treeb6c2accd917ddeb2a599989758989f2a259fbfe4 /hw6
parentcommit (diff)
downloadhomework-6-raquel191-fc6a16dd4adfb6a5daf0a291e85e571c6b5866cb.tar.xz
homework-6-raquel191-fc6a16dd4adfb6a5daf0a291e85e571c6b5866cb.zip
delete fun
Diffstat (limited to 'hw6')
-rw-r--r--hw6/hw6/contacts.cpp19
-rw-r--r--hw6/hw6/contacts.h2
-rw-r--r--hw6/hw6/program.cpp24
3 files changed, 40 insertions, 5 deletions
diff --git a/hw6/hw6/contacts.cpp b/hw6/hw6/contacts.cpp
index 05cd8ea..6341407 100644
--- a/hw6/hw6/contacts.cpp
+++ b/hw6/hw6/contacts.cpp
@@ -49,20 +49,35 @@ void Printcontacts(contact(&contacts)[10]) {
}
void update(contact(&contacts)[10]) {
- cout << "Print contact to update" << endl;
+
Printcontacts(contacts);
int num = 0;
+ cout << "Contacts nummbers start from 0." << endl;
cout << "Enter contact number to update" << endl;
cin >> num;
contacts[num] = InputNewcontact();
+ }
+
+void Delete(contact(&contacts)[10]) {
+
+ Printcontacts(contacts);
+ int number = 0;
+ cout << "Contacts nummbers start from 0." << endl;
+ cout << "Enter number of contact you wish to delete: " << endl;
+ cin >> number;
-
+ for (int i = number - 1; i < number; i++) {
+ contacts[number] = contacts[number + 1];
}
+ number--;
+ //contacts[number] =
+
+}
diff --git a/hw6/hw6/contacts.h b/hw6/hw6/contacts.h
index 44b962d..fc66fe0 100644
--- a/hw6/hw6/contacts.h
+++ b/hw6/hw6/contacts.h
@@ -20,4 +20,6 @@ void Printcontacts(contact(&contacts)[10]);
void update(contact(&contacts)[10]);
+void Delete(contact(&contacts)[10]);
+
#endif
diff --git a/hw6/hw6/program.cpp b/hw6/hw6/program.cpp
index cc043c9..cec8fd0 100644
--- a/hw6/hw6/program.cpp
+++ b/hw6/hw6/program.cpp
@@ -15,18 +15,27 @@ const int Max = 10;
contact contacts[Max] = {};
int numberofcontacts = 0;
-char c = 'n';
+//int* array = new int[3];
+int* newcontacts = new int[3];
-int main() {
+char c = 'n';
+
+int main() {
+ /*if (newcontacts 3) {
+ if (auto i = 0u; i < 3; ++i) {
+ newcontacts = new int[3 * 2];
+ }
+ }*/
do {
//system("cls");
cout << "A. Input New Contact\n";
cout << "B. Update contacts\n";
cout << "C. Print contacts\n";
+ cout << "D. Delete a contacat\n";
cout << "press 'x' to exit\n";
std::cin >> c;
@@ -52,10 +61,15 @@ int main() {
break;
case'C':
-
+ cout << "Here are all the contacts: " << endl;
Printcontacts(contacts);
break;
+ case 'D':
+
+ Delete(contacts);
+ break;
+
case 'x':
//exit
cout << "Goodbye";
@@ -66,6 +80,10 @@ int main() {
} while (c != 'x');
+
+
+
+
return 0;
}