#include <iostream>
using namespace std;
int main()
{
int x;
cin >> x;
if (x == EOF)
cout << x;
system("pause");
}
Inputting the EOF on Windows output nothing. While -1 outputs -1.
Over here
#include <iostream>
using namespace std;
int main()
{
int x;
if ((x=cin.get()) == EOF)
cout << x;
system("pause");
}
Inputting the EOF on Windows outputs -1. While -1 outputs nothing.
Now I am totally confused (I am working on 64-bit Windows 7 with Visual Studio 2015; though I do not think this is related)
I also want to add if "x" is assigned EOF in both cases, from where the difference came? I am comparing the value of "x" to EOF in both cases, right?