How I restrict user from giving more input?

When I ask the user to give input using cin method, sometimes user give more than required number of input using spaces :frowning: and my program will halt/doesn’t work !
How do I stop the user from giving extra input ?
or how do I flush the extra inputs ?