[ad_1]
Both are same. fail is a typical function where is ‘!’ is an overloaded operator. You may want to check reference http://www.cplusplus.com/reference/ios/ios/fail/ before posting.

1
[ad_2]
solved What’s the difference between cin.fail() and !cin in C++?