This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jun 24th, 2012  |  syntax: C  |  size: 0.45 KB  |  views: 4  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }
clone this paste RAW Paste Data