Never do unary minus on sizeofThis tip submitted by Vaibhav on 2006-01-15 02:13:54. It has been viewed 22085 times.
Rating of 6.2 with 160 votes
What will be output of
No, it's not -1, it is 4294967295!
The return type of sizeof is size_t (similar to unsigned int). If you try to use -sizeof() you can now understand what will happen. Once I used it in seekg() function and spent nearly 6 hours debugging it before I finally spotted it.
Help your fellow programmers! Add a tip!