提问人:ajoseps 提问时间:2/23/2023 更新时间:2/23/2023 访问量:81
为什么将 nullptr 值传递给 ostream 会停止打印到 stdout?[复制]
why does passing a nullptr value to an ostream stop printing to stdout? [duplicate]
问:
$ g++ --version
g++ (GCC) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ g++ test.cpp -o test -g
test.cpp
#include <iostream>
int main() {
const char * c = nullptr;
std::cout << "testing: " << c << std::endl;
std::cout << "why does this not print?" << std::endl;
return 0;
}
运行:test
$ ./test
testing: $ echo $?
0
似乎阻止了进一步打印,但我不确定为什么。似乎没有被处理,如果我只是通过而不是.nullptr
stdout
std::endl
\n
std::endl
答: 暂无答案
评论
cout