file redirection

This is a discussion on file redirection within the C++ Programming forums, part of the General Programming Boards category; hi everyone, I would like to know if file redirection can also be used compilers installed in Win32...like the one ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    28

    file redirection

    hi everyone,

    I would like to know if file redirection can also be used compilers
    installed in Win32...like the one I have called vide. the file redirection I am talking about is of this type...

    < $proramName> file1.txt > file2.txt

    if it is possible implementing with Win32 can anyone suggest
    how I can implement the above operation currently I have program that uses command line arguments that I run this
    way:

    <proramName> file1.txt

    and it outputs on the screen but I would like to redirect the output to another file.
    thanks in advance.

    this is just thebegining of the of my program.


    int main(int argc, char* argv[])
    {

    ifstream infile;

    if (argc != 2)
    {
    cerr<<"\n no file name specified " <<endl;
    exit(-1);
    }

    infile.open( argv[1] );
    if ( !infile )
    {
    cerr<<"\n can't open " << argv[1] <<endl ;
    exit(-1);
    }

    .
    .
    .

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,672
    If you want to do what I think you are talking about, you will need to change cerr to cout and then it should work. cerr is the output error stream and is non-redirectable, cout however will allow the output to be redirected to a file like you are attempting.
    I used to be an adventurer like you... then I took an arrow to the knee.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory Address
    By kevinawad in forum C++ Programming
    Replies: 18
    Last Post: 10-19-2008, 10:27 AM
  2. file processing updating record error
    By uuser in forum C Programming
    Replies: 2
    Last Post: 04-27-2003, 12:13 AM
  3. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  4. Hmm....help me take a look at this: File Encryptor
    By heljy in forum C Programming
    Replies: 3
    Last Post: 03-23-2002, 09:57 AM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 01:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21