3

I have this code:

#include <iostream>
#include <vector>

int main()
{
    std::vector<int> vec;
    int num = 0;
    while (std::cin >> num)
        vec.push_back(num);
    std::cout << std::cin.eof() 
              << " " << std::cin.fail()
              << std::endl;
    return 0;
}

when I run it with inputs: 8 6 4 1 ^Z , I get the output: 0 1 why is failbit set when hitting end-of-file but eofbit is not, why is failbit set at all when hitting end-of-file

Igracx33
  • 389
  • 1
  • 3
  • 8

0 Answers0