+ 3

Please explain this:

#include <iostream> using namespace std; int main() { cout<<main; getchar(); return 0; }

9th Apr 2018, 7:19 PM
Naman
Naman - avatar
3 Réponses
+ 3
I believe 1 is the compilers default false value. ref: http://www.cplusplus.com/forum/beginner/147175/
10th Apr 2018, 10:35 AM
Manual
Manual - avatar
+ 6
Sure, When you start a C++ code, int main is false by default ( any value that is not 0 - the 1 ). Why, because the compiler need to know if the code finishes or not. getchar() - takes a character like 'a' for input ( C like function inputs do not work well in the C++ playground) return 0; - main becomes true the compiler knows that the code is done
9th Apr 2018, 9:11 PM
Manual
Manual - avatar
0
Manual and why it's output is 1?
10th Apr 2018, 4:15 AM
Naman
Naman - avatar