title: The correct way to test 'SDL_PollEvent' in a 'while'
body: <p>As the manual says, the function <code>SDL_PollEvent</code> "Returns 1 if there is a pending event or 0 if there are none available." , that's why we use the test <code>SDL_PollEvent(&amp;e)!=0</code> (where <code>e</code> is a <code>SDL_Event</code>).<br></p>
  
  <p>But, what about use this test: <code>!SDL_PollEvent(&amp;e)</code>? It should work,but apparently it cause some problem.<br></p>
  
  <p>Here an example of code:</p>
  
  <pre><code>    #include &lt;SDL2/SDL.h&gt;
      #include &lt;stdio.h&gt;
  
      int main(int argc, char* args[]){
        SDL_Init(SDL_INIT_VIDEO);
        SDL_Window* window =   SDL_CreateWindow("Hello",SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 100, 100,  SDL_WINDOW_SHOWN);
        SDL_Event e;
        int quit=0;
        while(!quit){
            //Here the test
            while (!SDL_PollEvent(&amp;e)){
               if (e.type==SDL_QUIT)
                  quit=1;
               else if ( e.type == SDL_KEYDOWN )
                  printf( "Hello\n" );
            }
        }
        SDL_DestroyWindow(window);
        SDL_Quit();
        return 0;
     }
  </code></pre>
  
  <p>What this code should do is open a new window and print "Hello" in the console every time a key is pressed. This code works fine whit the test <code>SDL_PollEvent(&amp;e)!=0</code> but it doesn't read the <code>SDL_KEYDOWN</code> event when I use the test <code>!SDL_PollEvent(&amp;e)</code> (but it DOES enter in the while and process the <code>SDL_QUIT</code> event without any problem).<br>
  Why this behaviour?</p>