Back to questions
JuniorTheoryOccasional
What does the program print?
#include <iostream>
int main() {
std::cout << "A";
return 0;
std::cout << "B";
}A
- Expecting
AB:returnendsmainat once, so the statement after it never runs. - Expecting a compile error: code after
returncompiles, but it never runs.
- Why does the compiler accept the line printing
B, even though it can never run? - Is output sent to
std::coutwithout a trailing newline still printed whenmainreturns?