Jump to content

Limpar Buffer cin


zecapistolas

Recommended Posts

Boas Pessoal,

Estou com um daqueles problemas ridículos  :wallbash:, que é, tenho uma série de "cout's" e "cin's" todos misturados, mas como não limpo o buffer do cin, às vezes o '\n' fica lá e o programa salta algumas instruções 'cin'....  ?

Encontrei isto na net:

std::cin.clear();
// Ignore to the end of line
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n')

Mas ao compilar dá-me estes erros (e é na segunda linha do exemplo anterior):

error: ‘numeric_limits’ is not a member of ‘std’

error: expected primary-expression before ‘>’ token

error: ‘::max’ has not been declared

Será que me falta algum include?!  ?

cumps  👍

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.