SHARE
TWEET

Untitled

a guest Nov 19th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. char *Calendar::print()
  2. {
  3.     char *buffer = nullptr;
  4.     char *printArr = nullptr;
  5.     int cnt = 0;
  6.     for (int i = 0; i < 30; ++i)
  7.     {
  8.         if (m_myDate[i] != nullptr)
  9.         {
  10.             buffer = m_myDate[i]->print();
  11.             cnt += strlen(buffer) + 1;
  12.             printArr = (char *)realloc(printArr, cnt);
  13.             strcpy(printArr + (cnt - 12), buffer);
  14.             *(printArr + cnt - 1) = ' ';
  15.             *(printArr + cnt - 2) = ' ';
  16.             delete[] buffer;
  17.         }
  18.     }
  19.  
  20.     if (printArr == nullptr)
  21.     {
  22.         cout << "Empty Calendar" << endl;
  23.         return NULL;
  24.     }
  25.  
  26.     *(printArr + cnt - 1) = '\0';
  27.  
  28.     return printArr;
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top