C++ Quiz142 of 173
Difficulty:
⬅️ Prev: 291Quiz ID: 293Next: 295 ➡️

According to the C++23 standard, what is the output of this program?

#include <iostream>

int main(int argc, char* argv[]) {
    std::cout << (argv[argc] == nullptr);
}
Hint

There is no bug in this program, the programmer is supposed to be able to do this.

Reveal answer

1

Explanation

You might think we access an out-of-bounds array element and the program behaviour is undefined, but §[basic.start.main]¶2 explicitly states:

The value of argv[argc] shall be 0.

⬅️ Prev: 291Quiz ID: 293Next: 295 ➡️