Thread: catching output

  1. #1
    Registered User
    Join Date
    Jul 2004

    catching output

    any ideas?

    ok, i wrote a program that copies files. now i need to time the execution of that program using different buffer sizes
     time prog_name
    the thing is that i need to run it several times for each buffer size and provide averages in a report. whad i't like to do is write another program that does that i just use a system call:
    system("time cop");
    . the only thing is that i'd like to know if i can catch the output that this provides in a variable.

    ya, i know, redirect to a file, read the file, place the values into variables, do calculations. BUT if time command prints to standard out, how can i catch that and place it into a variable while the time program is running????

    using SuSE

    any ideas????
    Last edited by judoman; 07-28-2004 at 09:36 AM.

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Oregon, USA
    Check out the popen() function. You should be able to use that in "r" mode instead of using system() to catch the output of the program.

  3. #3
    Registered User
    Join Date
    Jul 2004

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help for my output array
    By qwertysingh in forum C Programming
    Replies: 1
    Last Post: 02-17-2009, 03:08 PM
  2. execl()/fork() output
    By tadams in forum C Programming
    Replies: 19
    Last Post: 02-04-2009, 03:29 PM
  3. Replies: 4
    Last Post: 11-30-2005, 04:44 PM
  4. Formatting output into even columns?
    By Uncle Rico in forum C Programming
    Replies: 2
    Last Post: 08-16-2005, 05:10 PM
  5. Output problems with structures
    By Gkitty in forum C Programming
    Replies: 1
    Last Post: 12-16-2002, 05:27 AM