Hello and welcome. Next time you post code, select it and hit “control E” on your keyboard, it will tell the website to wrap it in code formatting.
For your problem:
Try drawing a large background image before drawing the sprite, or use SDL_FillRect to fill the window background with a solid color.
Using either of these methods will clear the afterimage of the sprite.
SDL_Rect rect;
rect.x = 462 + move_sprite;
rect.y = 686 + player.y;
SDL_BlitSurface(gHelloWorld_one, &rects[frame], gScreenSurface, &rect);
SDL_FillRect(gHelloWorld_one, &rect, 0x00);
frame++;
well I tried this but I am still getting afterimages
It might be easier to just redraw everything each frame (the whole background, all the sprites, etc.), especially if you add more complicated backgrounds and sprites to your game. This might seem like it would be inefficient, which it can be if you continue to do “software rendering” (with SDL_Surface). It can often be made to perform good enough by implementing a “dirty rectangle system” (and use SDL_UpdateWindowSurfaceRects instead of SDL_UpdateWindowSurface) assuming there is not too much moving around all the time, but if you instead start using the Render API (by using SDL_Texture instead of SDL_Surface, SDL_RenderCopy instead of SDL_BlitSurface, SDL_RenderPresent instead of SDL_UpdateWindowSurface, etc.) then you’ll take better advantage of your GPU (graphics card) so redrawing everything on the screen each frame should no longer be a performance problem (especially not for a simple 2D game). I believe most modern SDL games do it this way.
Hmm, didn’t think about this earlier, but you actually want to fill the rect from the previous iteration and not the current. And if you ever add more than one sprite you will have to do this at the start of the loop, before drawing any sprites, because you don’t want one sprite to accidentally draw the background on top of another sprite.
Consider simply redrawing the whole background once on each iteration by passing null for the rect.