Thread: redirect stdout to a file?

  1. #1
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,212

    redirect stdout to a file?

    I want to redirect stdout to a file.

    say I did:
    Code:
    system("dir /b /s c:\\*.txt");
    this would display all the text files on drive C in plain format (one line per file and no details /b does this). I want to redirect this to a file, so my program can search through the txt files for the one it needs.

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Lookup freopen();

    Its part of <stdio.h>

    Though for that task you would do better to lookup findfirst() and findnext() to get the files. The method you are suggesting is very slow and cumbersome...

  3. #3
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,212
    Will do, cheers.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    *shrug*
    system("dir /b /s c:\\*.txt > wibble.lst");

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by Salem
    *shrug*
    system("dir /b /s c:\\*.txt > wibble.lst");
    LOL....oh yeah

    :: hits head ::

  6. #6
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,212
    lol even better

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  3. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  4. Making a LIB file from a DEF file for a DLL
    By JMPACS in forum C++ Programming
    Replies: 0
    Last Post: 08-02-2003, 08:19 PM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM