How can you redirect error messages in a C program to a file instead of displaying them on the console?
- stderr_redirect()
- errorToFile()
- file_error()
- freopen()
The correct option is freopen(). This function can be used to redirect standard error (stderr) to a file. By using freopen("error.log", "w", stderr), error messages will be written to the specified file instead of the console.
Loading...
Related Quiz
- In C, a double pointer is a pointer that points to another ________.
- What is the purpose of using pointers to structures in C programming?
- In a 'switch' statement, the ________ keyword is used to specify the code to execute if none of the cases match.
- In C, a function pointer can be used to call a function without knowing its ________ at compile time.
- What is the primary cause of memory leaks in a C program?