How to Clamp mouse position in C++?

So I need to clamp my mouse position for my project, so that mouse doesn’t go higher than X = 420.
Mouse should not go to the end of the screen what would usually be the case, but be clamped.
Can someone help me with code?