JonnySilver
Junior Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Под NT и прочими Win не сработает, так как stderr - выводится только на консоль. А вот так можно проблему решить. Вот справка и пример из MSDN: Цитата: These are standard streams for input, output, and error output. By default, standard input is read from the keyboard, while standard output and standard error are printed to the screen. The following stream pointers are available to access the standard streams: Pointer Stream stdin Standard input stdout Standard output stderr Standard error These pointers can be used as arguments to functions. Some functions, such as getchar and putchar, use stdin and stdout automatically. These pointers are constants, and cannot be assigned new values. The freopen function can be used to redirect the streams to disk files or to other devices. The operating system allows you to redirect a program's standard input and output at the command level. Example /* FREOPEN.C: This program reassigns stderr to the file * named FREOPEN.OUT and writes a line to that file. */ #include <stdio.h> #include <stdlib.h> FILE *stream; void main( void ) { /* Reassign "stderr" to "freopen.out": */ stream = freopen( "freopen.out", "w", stderr ); if( stream == NULL ) fprintf( stdout, "error on freopen\n" ); else { fprintf( stream, "This will go to the file 'freopen.out'\n" ); fprintf( stdout, "successfully reassigned\n" ); fclose( stream ); } system( "type freopen.out" ); } | | Всего записей: 151 | Зарегистр. 03-09-2003 | Отправлено: 21:19 31-05-2004 | Исправлено: JonnySilver, 21:29 31-05-2004 |
|