Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef struct house{
- int id;
- int lotarea;
- char street[5];
- int saleprice;
- char neighborhood[10];
- int yearbuilt;
- int overallqual;
- int overallcond;
- char kitchenqual[3];
- } House;
- House* get_neighborhoods(House house, House* array) {
- printf("Get neighborhoods of house with id %dn", house.id);
- House* temp = array;
- int counter = 1;
- House* newarray = malloc(sizeof(House));
- if (newarray == NULL) {
- printf("Malloc error...");
- }
- while (temp != NULL) {
- if (!strcmp(temp->neighborhood, house.neighborhood)) {
- if (counter > 1) {
- realloc(newarray, sizeof(House) * counter);
- }
- copy_house(newarray + counter - 1, temp);
- print_house(newarray[counter - 1]);
- counter++;
- }
- temp++;
- }
- return newarray;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement