Advertisement
Andrey_ZoZ

setChar

Jun 23rd, 2020
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. void setChar(char* type)
  2.     {
  3.         delete[] this->type;
  4.         if (type != nullptr)
  5.         {
  6.             this->type = new char[strlen(type) + 1];
  7.             for (int i = 0; type[i]!='\0'; i++)
  8.             {
  9.                 this->type[i] = type[i];
  10.             }
  11.             this->type[strlen(type)] = '\0';
  12.         }
  13.         else { this->type = nullptr; }
  14.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement