cerr and clog

Discussion in 'C++' started by Scott, Jun 16, 2006.

  1. Scott

    Scott Guest

    Hello,

    I am not entirely clear on the difference between cerr and clog. When it
    is more appropriate to use one versus the other? I am coding a simple C++
    application that will issue error and warning statements based on an
    input, and I would like to know whether these should both go to cerr, or
    whether clog for warnings is a more appropriate choice (or I suppose, just
    cout)?

    Thank-you,
    Scott
     
    Scott, Jun 16, 2006
    #1
    1. Advertising

  2. Scott

    Gnafu Guest

    > I am not entirely clear on the difference between cerr and clog.

    They only are tow different streams..

    > When it is more appropriate to use one versus the other? I am coding a

    simple C++
    > application that will issue error and warning statements based on an
    > input, and I would like to know whether these should both go to cerr, or
    > whether clog for warnings is a more appropriate choice (or I suppose, just
    > cout)?
    >


    Yes..
    Some time ago, i red an article describing the way to get the streams into
    different files using windows.

    I've found this:

    ----------------------------------------------------------------------------------------------
    Redirection, Pipes and Filters

    Redirection
    Directing output ( > ) from a program to a specific file or device
    (different from the 'standard output' device: the screen).
    Directing input ( < ) to a program from a specific file or device (different
    from the 'standard input' device: the keyboard).
    Pipe
    A data-channel ( | ) in RAM that takes output from a program and feeds the
    data as input to another program.
    Filter
    A program that accepts input data - does something to the data - and
    delivers output data.
    Both input and output may be redirected or piped.
    DOS filters: find, more, sort

    Examples:

    dir > list.txt redirect output from dir to the file list.txt
    - if the file does not exist, it is created
    - if the file exists, it is overwritten.
    dir >> list.txt redirect and append output from dir to the file list.txt
    - if the file does not exist, it is created
    - if the file exists, output is appended to end of file.
    sort < names.txt > list.txt use the file names.txt as input to sort
    - output from sort is sent to the file list.txt.
    dir | sort pipe output from dir to sort
    - output from sort is sent to standard output: the screen.
    dir | sort > c:\temp\list.txt - output from sort is sent to the file
    c:\temp\list.txt.
    dir | sort | more - output from sort is piped to more
    - more (a filter) delivers output one screenfull at a time.

    Redirection and pipes may be used in batch files.
    -----------------------------------------------------------------------------------

    but i can't remember how to split the streams... sorry

    bye bye

    Gnafu
     
    Gnafu, Jun 18, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fuzzyman

    Nappy Clog Month.........

    Fuzzyman, Feb 9, 2004, in forum: Python
    Replies:
    0
    Views:
    306
    Fuzzyman
    Feb 9, 2004
  2. Scott

    redirecting clog

    Scott, Mar 13, 2006, in forum: C++
    Replies:
    3
    Views:
    508
    Scott
    Mar 14, 2006
  3. ksamdev
    Replies:
    3
    Views:
    414
    Stuart Redmann
    Sep 13, 2010
  4. ksamdev
    Replies:
    2
    Views:
    1,199
    ksamdev
    Sep 10, 2010
  5. Jeff Flinn
    Replies:
    0
    Views:
    397
    Jeff Flinn
    Sep 11, 2010
Loading...

Share This Page