Hi,

Is there a way to set stderr such that it does not print on screen rather on file. I have spawned a couple of threads and they are dumping all the error messages on the screen like a maniac and giving me a headache.

Some help would be highly appreciated.

Thanks.

Recommended Answers

All 2 Replies

Try googling freopen()...plus here's a small example of redirecting stderr to a file named output.

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char**argv)
{
	freopen("output", "w", stderr);

	fputs("send this to stderr\n", stderr);
	exit(EXIT_SUCCESS);
}

Not normally, although you can pipe stderr to a file by using 2 in front of the pipe character: prog 2>err.file

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.