SHARE
TWEET

Untitled

a guest Jun 24th, 2012 7 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
Want to get better at C?
Learn to code C in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top