Advertisement
Guest User

Untitled

a guest
May 6th, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. void aieString::Append(const char* strToAppend)
  2. {
  3.     // temporary array for copying
  4.     char tmpArray[256] = {};
  5.     // copy data values to new array
  6.     for (int i = 0; i < length; i++)
  7.     {
  8.         tmpArray[i] = data[i];
  9.     }
  10.     // copy strToAppend to the end of the temporary
  11.     // array, up until the null terminator, when the
  12.     // null terminator appears, wipe the data *char.
  13.     // Make data's values correspond to the temporary
  14.     // arrays values. Add the null terminator at the end,
  15.     // and finally, break out of the loop, and function.
  16.     for (int i = 0; i < 128; i++)
  17.     {
  18.         if (strToAppend[i] != '\0')
  19.         {
  20.             tmpArray[length] = strToAppend[i];
  21.             length++;
  22.         }
  23.         else
  24.         {
  25.             data = new char[length];
  26.             for (int j = 0; j < length; j++)
  27.             {
  28.                 data[j] = tmpArray[j];
  29.             }
  30.             data[length] = '\0';
  31.             break;
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement