title: malloc in a while loop
body: <p>In the below code, I have put a malloc call in a while loop <br></p>
  
  <pre><code>int main()
  {
      int *ptr;
      while(1) { 
          ptr=malloc(1000);
          if (ptr == NULL) break;
      }
      return (0);
  }
  </code></pre>
  
  <p>Will the <code>while loop</code> run until there is space left in heap or will it continue to run forever unless it is killed since we are not writing any data in the allocated memory?
  Of course there is a memory leak which is intended so that the above question can be answered.</p>