|
-
January 17th, 2009, 06:10 PM
#1
strcmp stdout, stderr and stdin .. more
Code:
class File_Driver {
FILE *op ;
FILE *ip;
bool op_open ;
bool ip_open ;
public :
File_Driver ( const char* in_file_name, const char* out_file_name )
: op ( 0 )
, ip ( 0 )
, op_open ( false )
, ip_open ( false )
{
if ( in_file_name ) {
if ( strcmp ( in_file_name, "stdin" ) == 0 ) {
op = stdin ;
}
} else {
ip = fopen ( in_file_name, "rb" ) ;
if ( ip ) ip_open = true;
}
if ( out_file_name ) {
if ( strcmp ( in_file_name, "stdout" ) == 0 ) {
op = stdout ;
}
} else if ( strcmp ( in_file_name, "stderr" ) == 0 ) {
op = stderr;
} else {
op = fopen ( out_file_name, "wb" ) ;
if ( op ) op_open = true;
}
}
};
I'm trying to rewrite the source code above to use C++ streams. What I'm not following however, is the string comparisons (strcmp) to stdout, stderr and stdin and assignment to the member variable op if comparisons == 0. Why is that necessary ( not sure if that's some 'Cism') or ... ?
Thanks in advance
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|