Fixed structure recursion.

This commit is contained in:
Ernie Pasveer
2023-11-15 16:30:47 -06:00
parent b96ad46859
commit 8f5dee9842
5 changed files with 105 additions and 136 deletions
+15 -11
View File
@@ -21,11 +21,16 @@ struct Person {
struct Location location;
};
void print(const Location& where) {
std::cout << "From '" << where.city << std::endl;
}
int main (int argc, char** argv) {
Person me;
Person you;
Location where;
me.name = "Pasveer, Ernie";
me.age = 60;
@@ -36,22 +41,21 @@ int main (int argc, char** argv) {
me.location.cell = (Cell*)malloc(sizeof(Cell));
me.location.cell->number = 2226669999;
you.name = "Pitt, Dirk";
you.age = 60;
you.salary = 0.25;
you.location.city = "Houston";
you.location.state = "Texas";
you.location.zip = 77063;
you.location.cell = (Cell*)malloc(sizeof(Cell));
you.location.cell->number = 2226669999;
where.city = "Houston";
where.state = "Texas";
where.zip = 77063;
where.cell = (Cell*)malloc(sizeof(Cell));
where.cell->number = 2226669999;
std::cout << "'" << me.name << "', from '" << me.location.city << "', is " << me.age << " years old and makes " << me.salary << " per year." << std::endl;
print(where);
free(me.location.cell);
free(you.location.cell);
free(where.cell);
me.location.cell = 0;
you.location.cell = 0;
where.cell = 0;
return 0;
}