How to move a rectangle in SDL2 using C
<p>I'm unable to move the rectangle I made in the program. There is no error message in the compiler when I run the program. Can you please tell me what I missed out in the keyboard event. Other event that I assigned to the window works fine. Instead of writing instructions down can you please show me the solution. I have been on this forever. Thanks</p>

<pre><code>#include &lt;SDL.h&gt;
#include &lt;stdlib.h&gt;

int main()
{
    SDL_Window *o;
    SDL_Renderer *r;
    SDL_Event e;
    SDL_Rect q;
    int i =1;

    SDL_Init(SDL_INIT_VIDEO);

    o = SDL_CreateWindow("Game test",
                            SDL_WINDOWPOS_UNDEFINED,
                            SDL_WINDOWPOS_UNDEFINED,
                            1024,
                            800,
                            SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);

    r = SDL_CreateRenderer(o, -1,SDL_RENDERER_ACCELERATED);

    while(i)
    {
        while(SDL_PollEvent(&amp;e) !=0)
        {
            if(e.type == SDL_QUIT)
                i=0;
            else if(e.type == SDL_KEYDOWN)
            {
                switch(e.key.keysym.sym)
                {
                case SDLK_ESCAPE:
                case SDLK_q:
                    i=0;
                break;
                case SDLK_UP:
                    q.y -=10;
                break;
                case SDLK_DOWN:
                    q.y +=10;
                break;
                case SDLK_RIGHT:
                    q.x +=10;
                break;
                case SDLK_LEFT:
                    q.x -=10;
                break;
                }
            }
        }
        SDL_SetRenderDrawColor(r,0,0,255,255);
        SDL_RenderClear(r);
        // Creating the rectangle
        q.x=475;
        q.y=700;
        q.h=50;
        q.w=50;

        SDL_SetRenderDrawColor(r,0,0,0,255);

        SDL_RenderFillRect(r,&amp;q);

        SDL_RenderPresent(r);
    }

    SDL_DestroyWindow(o);
    SDL_DestroyRenderer(r);
    SDL_Quit();

    return 0;
}
</code></pre>