aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor McDowell <[email protected]>2024-02-21 16:17:47 -0800
committerConnor McDowell <[email protected]>2024-02-21 16:17:47 -0800
commita10ee9a9bc8e1a086e112a1e381b63d4a4c96112 (patch)
tree2cff8a565810dd99348c2447c884b6dde7a20393
parentstill testing (diff)
downloadhomework-6-connormcdowell275-a10ee9a9bc8e1a086e112a1e381b63d4a4c96112.tar.xz
homework-6-connormcdowell275-a10ee9a9bc8e1a086e112a1e381b63d4a4c96112.zip
pushing
-rw-r--r--Project1/Contacts.h28
-rw-r--r--Project1/contacts.cpp28
-rw-r--r--Project1/program.cpp13
3 files changed, 49 insertions, 20 deletions
diff --git a/Project1/Contacts.h b/Project1/Contacts.h
index ba605fc..0119030 100644
--- a/Project1/Contacts.h
+++ b/Project1/Contacts.h
@@ -10,24 +10,36 @@ struct contact
bool a = true;
size_t id = 0;
size_t count = 0;
- char Name[25]{};
- char Email[100]{};
- char StreetAddress[35]{};
- char City[30]{};
- char State[3]{};
+ char Name[30]{};
+ char Email[105]{};
+ char StreetAddress[45]{};
+ char City[35]{};
+ char State[4]{};
int Zip = 0;
};
-//contact newContact[11];
+//struct contact
+//{
+// bool a = true;
+// size_t id = 0;
+// size_t count = 0;
+// char Name[25]{};
+// char Email[100]{};
+// char StreetAddress[35]{};
+// char City[30]{};
+// char State[3]{};
+// int Zip = 0;
+//};
+//contact newContact[11];
int menu();
-char addNew(contact newContact[], size_t MAX, size_t t);
+char addNew(contact newContact[], size_t MAX, size_t& t);
void update(contact newContact[], size_t MAX);
-void printAll(contact newContact[], size_t MAX);
+void printAll(contact newContact[], size_t& MAX);
contact contact_double(contact*& newContact, size_t& MAX, size_t t);
diff --git a/Project1/contacts.cpp b/Project1/contacts.cpp
index 162d30b..a35c74f 100644
--- a/Project1/contacts.cpp
+++ b/Project1/contacts.cpp
@@ -7,7 +7,7 @@ using std::cin;
using std::cout;
using std::endl;
-char addNew(contact newContact[], size_t MAX, size_t t)
+char addNew(contact newContact[], size_t MAX, size_t& t)
{
//using couts to prompt using for all parts of newContact struct.
//update plans: check for newContact[i].bool value, if false, use a modified void update
@@ -37,6 +37,7 @@ char addNew(contact newContact[], size_t MAX, size_t t)
cout << "Please enter the next value as a series of numbers" << endl;
cout << "enter Zip: " << endl;
cin >> newContact[i].Zip;
+ t++;
break;
}
@@ -81,11 +82,11 @@ void update(contact newContact[], size_t MAX)
}
}
-void printAll(contact newContact[], size_t MAX)
+void printAll(contact newContact[], size_t& MAX)
{
//prints all info but count and bool for every existing (non trash value filled) contact struct
//CURRENTLY WORKING
- for (int i = 0; i < MAX; ++i)
+ for (size_t i = 0; i <= MAX; ++i)
{
/*for (int t = -1; t < newContact[i].id;) {
break;
@@ -118,12 +119,29 @@ contact contact_double(contact*& newContact, size_t& MAX, size_t t)
contact* doubleContact = new contact[MAX * 2];
for (auto a = 0u; a < MAX; ++a)
{
- doubleContact[a] = newContact[a];
+ doubleContact[a].a = newContact[a].a;
+ doubleContact[a].id = newContact[a].id;
+ doubleContact[a].count = newContact[a].count;
+ doubleContact[a].Name[25] = newContact[a].Name[25];
+ doubleContact[a].Email[100] = newContact[a].Email[100];
+ doubleContact[a].StreetAddress[35] = newContact[a].StreetAddress[35];
+ doubleContact[a].City[30] = newContact[a].City[30];
+ doubleContact[a].State[3] = newContact[a].State[3];
+ doubleContact[a].Zip = newContact[a].Zip;
+ cout << "List number: " << doubleContact[a].id << endl;
+ cout << "name: " << doubleContact[a].Name << endl;
+ cout << "Email: " << doubleContact[a].Email << endl;
+ cout << "Address: " << doubleContact[a].StreetAddress << endl;
+ cout << "city: " << doubleContact[a].City << endl;
+ cout << "state: " << doubleContact[a].State << endl;
+ cout << "Zip: " << doubleContact[a].Zip << endl;
}
newContact = doubleContact;
delete[] doubleContact;
+ //delete[] newContact;
MAX = MAX * 2;
- printAll(&newContact[MAX], MAX);
+ //printAll(&doubleContact[MAX], MAX);
+ //printAll(&newContact[MAX], MAX);
return newContact[MAX];
}
diff --git a/Project1/program.cpp b/Project1/program.cpp
index 1f6c0c4..acf6c8a 100644
--- a/Project1/program.cpp
+++ b/Project1/program.cpp
@@ -20,7 +20,7 @@ int main()
size_t t = 0;
contact* newContact = new contact[MAX];
int length = sizeof(newContact[MAX]);
- cout << sizeof(newContact) << endl;
+ cout << sizeof(newContact[MAX]) << endl;
while (O == 1)
{
cout << MAX << endl;
@@ -33,6 +33,11 @@ int main()
cout << "5. Quit\n";
cout << "\nEnter your choice: " << endl;
cin >> c;
+ if (t == MAX)
+ {
+ newContact[MAX] = contact_double(newContact, MAX, t);
+ //MAX = max_double(MAX);
+ }
if (c == 1)
{
addNew(&newContact[MAX], MAX, t);
@@ -56,12 +61,6 @@ int main()
delete[] newContact;
//abort;
}
- ++t;
- if (t >= MAX)
- {
- newContact[MAX] = contact_double(newContact, MAX, t);
- //MAX = max_double(MAX);
- }
}
return 0;
} \ No newline at end of file