I wrote a C++ demo test.cpp
like:
int main()
{
int num = 1 / 0;
}
then compiled it
$ g++ test.cpp -o test
then run it in shell:
$ ./test 2>error.txt
I expected the error messages to be redirected to error.txt, but they still print on the screen through stdout. Why did that happen?
The output shows as below:
Floating point exception (core dumped)