Thread: file redirection

  1. #1
    Registered User
    Join Date
    Apr 2002

    file redirection

    hi everyone,

    I would like to know if file redirection can also be used compilers
    installed in 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

    <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;
    } argv[1] );
    if ( !infile )
    cerr<<"\n can't open " << argv[1] <<endl ;


  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Northern Virginia/Washington DC Metropolitan Area
    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.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed

Similar Threads

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