Here is what the code you posted does:
- You initialise mx and my to zero
- You append these values into the stringstreams
- You render these stringstreams to SDL_Surfaces
- If a mouse event occurred, you update the mx and my variables using SDL_GetMouseState()
- You blit the surfaces to the game surface
Note that the order of operations is very important. You need to update the variables before appending them to the stringstream.