N
N
Nexeon2016-01-07 17:38:48
Programming
Nexeon, 2016-01-07 17:38:48

Threads: How is cin.goodbit different from cin.good()?

Good evening, I'm trying to understand threads and the i/o library
What is different about this code:

int i;
cin » i;
auto flag = cin.rdstate();
if (flag == cin.goodbit) cout « "Все в порядке!"; //если ввести целочисленное значение
cin.clear()

From this:
int i; 
cin » i;
if (cin.good()) cout « "Все в порядке!"; //если ввести целочисленное значение
cin.clear()

If both produce the same result. So what is the difference then and which way is better to use?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AtomKrieg, 2016-01-07
@MrNexeon

It is better to use good(), why write what is already written in it:
www.cplusplus.com/reference/ios/ios/good
read carefully

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question