Thread: Read command line and write to file or string

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    6

    Read command line and write to file or string

    Hi, all

    Please help me this case,

    I want to read command line and write this value to file or string, but i could not

    Example: I use system function below
    system("java -version"); I don't know how can I get this value to write to a file or store in string

    Please help

    thanks
    Last edited by miiisuuu; 10-21-2007 at 10:16 AM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Use popen() to run a command, and collect the output of the command as if you were reading from a file opened with fopen().
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Read and write binary file?
    By Loic in forum C++ Programming
    Replies: 2
    Last Post: 10-29-2008, 05:31 PM
  2. write and read system calls
    By nacho4d in forum C Programming
    Replies: 4
    Last Post: 01-28-2008, 10:59 AM
  3. Replies: 20
    Last Post: 07-24-2007, 11:47 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Hmm....help me take a look at this: File Encryptor
    By heljy in forum C Programming
    Replies: 3
    Last Post: 03-23-2002, 10:57 AM