Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. typedef struct house{
  2. int id;
  3. int lotarea;
  4. char street[5];
  5. int saleprice;
  6. char neighborhood[10];
  7. int yearbuilt;
  8. int overallqual;
  9. int overallcond;
  10. char kitchenqual[3];
  11. } House;
  12.  
  13.  
  14.  
  15. House* get_neighborhoods(House house, House* array) {
  16. printf("Get neighborhoods of house with id %dn", house.id);
  17.  
  18. House* temp = array;
  19. int counter = 1;
  20.  
  21.  
  22. House* newarray = malloc(sizeof(House));
  23.  
  24. if (newarray == NULL) {
  25. printf("Malloc error...");
  26. }
  27.  
  28.  
  29. while (temp != NULL) {
  30. if (!strcmp(temp->neighborhood, house.neighborhood)) {
  31.  
  32.  
  33. if (counter > 1) {
  34. realloc(newarray, sizeof(House) * counter);
  35. }
  36.  
  37. copy_house(newarray + counter - 1, temp);
  38. print_house(newarray[counter - 1]);
  39. counter++;
  40. }
  41.  
  42. temp++;
  43. }
  44.  
  45. return newarray;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement