2022-08-04 19:51:15 -05:00
|
|
|
#include <string>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2022-08-06 17:06:39 -05:00
|
|
|
|
2022-09-01 19:17:11 -05:00
|
|
|
struct Cell {
|
|
|
|
|
unsigned int number;
|
|
|
|
|
};
|
|
|
|
|
|
2022-08-06 17:06:39 -05:00
|
|
|
struct Location {
|
2022-08-21 15:53:35 -05:00
|
|
|
std::string city;
|
|
|
|
|
std::string state;
|
|
|
|
|
int zip;
|
2022-09-01 19:17:11 -05:00
|
|
|
struct Cell* cell;
|
2022-08-06 17:06:39 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct Person {
|
2022-08-21 15:53:35 -05:00
|
|
|
std::string name;
|
|
|
|
|
int age;
|
|
|
|
|
float salary;
|
|
|
|
|
struct Location location;
|
2022-08-04 19:51:15 -05:00
|
|
|
};
|
|
|
|
|
|
2023-11-15 16:30:47 -06:00
|
|
|
void print(const Location& where) {
|
|
|
|
|
|
|
|
|
|
std::cout << "From '" << where.city << std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-04 19:51:15 -05:00
|
|
|
|
|
|
|
|
int main (int argc, char** argv) {
|
|
|
|
|
|
|
|
|
|
Person me;
|
2023-11-15 16:30:47 -06:00
|
|
|
Location where;
|
2023-10-28 11:19:29 -05:00
|
|
|
|
|
|
|
|
me.name = "Pasveer, Ernie";
|
|
|
|
|
me.age = 60;
|
|
|
|
|
me.salary = 0.25;
|
|
|
|
|
me.location.city = "Houston";
|
|
|
|
|
me.location.state = "Texas";
|
|
|
|
|
me.location.zip = 77063;
|
|
|
|
|
me.location.cell = (Cell*)malloc(sizeof(Cell));
|
|
|
|
|
me.location.cell->number = 2226669999;
|
|
|
|
|
|
2023-11-15 16:30:47 -06:00
|
|
|
where.city = "Houston";
|
|
|
|
|
where.state = "Texas";
|
|
|
|
|
where.zip = 77063;
|
|
|
|
|
where.cell = (Cell*)malloc(sizeof(Cell));
|
|
|
|
|
where.cell->number = 2226669999;
|
2022-08-04 19:51:15 -05:00
|
|
|
|
2022-08-06 17:06:39 -05:00
|
|
|
std::cout << "'" << me.name << "', from '" << me.location.city << "', is " << me.age << " years old and makes " << me.salary << " per year." << std::endl;
|
2022-08-04 19:51:15 -05:00
|
|
|
|
2023-11-15 16:30:47 -06:00
|
|
|
print(where);
|
|
|
|
|
|
2022-09-04 12:01:51 -05:00
|
|
|
free(me.location.cell);
|
2023-11-15 16:30:47 -06:00
|
|
|
free(where.cell);
|
2022-09-04 12:01:51 -05:00
|
|
|
|
|
|
|
|
me.location.cell = 0;
|
2023-11-15 16:30:47 -06:00
|
|
|
where.cell = 0;
|
2022-09-04 12:01:51 -05:00
|
|
|
|
2022-08-04 19:51:15 -05:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|