SHARE
TWEET

Untitled

a guest Jun 24th, 2012 4 Never
  1. Booking **bookingSelectPaid(Booking **booking)
  2. {
  3.     Booking **ret = malloc(sizeof(Booking*));
  4.     size_t i = 0;
  5.     int numOfPaid = 0;
  6.     while (booking[i] != NULL)
  7.     {
  8.         if (booking[i]->paid == 1)
  9.         {
  10.             ++numOfPaid;
  11.             size_t newsize = sizeof(Booking*) * (numOfPaid + 1); ret = realloc(ret, newsize);
  12.             ret[i] = booking[i];
  13.             ret[i+1] = NULL;
  14.         }
  15.         ++i;
  16.     }
  17.     return ret;
  18. }
RAW Paste Data
Top