#include <iostream>
using namespace std;
int main()
{
if(sizeof(int)> -1)
cout<<"ok";
else
cout<<"not ok";
return 0;
}
Isn't size of int supposed to be 4, which should be greater than -1.
#include <iostream>
using namespace std;
int main()
{
if(sizeof(int)> -1)
cout<<"ok";
else
cout<<"not ok";
return 0;
}
Isn't size of int supposed to be 4, which should be greater than -1.
Two things:
sizeof(int)
can be any positive integral value. (I've worked on a system where sizeof(char)
, sizeof(int)
and sizeof(long)
were all 1 and were all 64 bit types.)
The type returned by sizeof
is an unsigned type. When comparing with -1
, -1
is converted to an unsigned value, with a high magnitude. Almost certainly sizeof(int)
will be less than that.