Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. int n;
  2. std::cin>>n;
  3.  
  4. char** p;
  5.  
  6. p = new char[n];
  7.  
  8. int second = 6;
  9.  
  10. //memory allocation
  11. for(int i = 0;  i < n; ++i)
  12. {
  13.     p[i] = new char[second];
  14.     ++second;
  15. }
  16.  
  17. //freeing memory
  18.  
  19. for(int i = 0; i < n; ++i;)
  20. {
  21.     delete[] p[i];
  22.     //p[i] = nullptr; C tva ne go podurja mai4e ;-;
  23.     p[i] = NULL;
  24. }
  25. delete[] p;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement