4 AnswersNew Answer
The sizeof operator returns a type of size_t. size_t is an unsigned data type. When -1 is converted to an unsigned data type, it will become the largest maximim value for that datatype. For a 32-bit build, that -1 will become 4,294,967,295 which is bigger than 4 (size of an int). In general: don't compare size_t to an int, and especially don't compare size_t to a negative int.
The return type of sizeof operator is size_t data type, the definition of size_t depends on its implementation, but it usually an unsigned type, in Sololearn, I think it's unsigned long long int. Because the return type is an unsigned type, the number -1 will be evaluated as positive. The format of -1 itself is (in Sololearn size_t type) 0xFFFFFFFFFFFFFFFF, which is practically the biggest number it can get. So, 4 is definitely not bigger than that
Yes, compare with zero if you like but not a negative number.
https://code.sololearn.com/cG495gBCZ332/?ref=app this is a solution to prevent the compiler from the logical error if u need more help to understand why you are welcome