title: How do i check whether the pointer is deleted or not in C++
body: <p>I have written following array pointer program in C++. I have deleted the pointer, but i am not able to confirm whether the pointer is deleted or not.
  Thanks in advance!</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  
  int main()
  {
      int *p;
      p=new int[10];
      int i=0;
  
  if(!p)
  {
      cout&lt;&lt;"\ndynamic memory allocation failed"&lt;&lt;endl;
  }
  
  cout&lt;&lt;&amp;p;
  
  for(i=0;i&lt;10;i++)
  {
      p[i]=i+1;
  }
  
  for(i=0;i&lt;10;i++)
      cout&lt;&lt;"\nvalue of pointer p="&lt;&lt;p[i];
  
  
  delete[] p;
  if(!p)
      cout&lt;&lt;"\n\nmemory cannot be free";
  }
  </code></pre>