Interact with console application

Discussion in 'C++' started by Oliver Witt, Aug 21, 2008.

  1. Oliver Witt

    Oliver Witt Guest

    Hi,

    I am coding a c++ application that is supposed to be capable of
    altering large text files. I want to use sed to do this. So I need to
    know how I can start sed from within the c++ program and how to get
    the return value (I do not want to write the result immediately into a
    file).

    This is another question, a little off topic, but if somebody happens
    to know... This program will be running on a Windows machine. I do not
    know how to tell sed if it is dealing with Unicode or Ascii encoded
    files.

    Thanks for any help,

    Oliver
     
    Oliver Witt, Aug 21, 2008
    #1
    1. Advertising

  2. Oliver Witt

    Jorgen Grahn Guest

    On Thu, 21 Aug 2008 06:04:01 -0700 (PDT), Oliver Witt <> wrote:
    > Hi,
    >
    > I am coding a c++ application that is supposed to be capable of
    > altering large text files. I want to use sed to do this.


    So you'll use "sed -i ..."; otherwise you cannot alter the files in
    place.

    > So I need to
    > know how I can start sed from within the c++ program and how to get
    > the return value (I do not want to write the result immediately into a
    > file).


    Use the ANSI C system() call. There are similar situations where
    you'd rather use popen(), like if you want your C++ code to interpret
    sed's output. Windows may have similar calls named Spawn-something.

    > This is another question, a little off topic, but if somebody happens
    > to know... This program will be running on a Windows machine. I do not
    > know how to tell sed if it is dealing with Unicode or Ascii encoded
    > files.


    Sorry, no. But what Unicode do you mean? There's UTF-8, and then
    there are encodings with 16 bits per character and so on. I'm not
    familiar with Windows.

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
    \X/ snipabacken.se> R'lyeh wgah'nagl fhtagn!
     
    Jorgen Grahn, Aug 21, 2008
    #2
    1. Advertising

  3. Oliver Witt

    Oliver Witt Guest

    > Use the ANSI C system() call.  There are similar situations where
    > you'd rather use popen(), like if you want your C++ code to interpret
    > sed's output.  Windows may have similar calls named Spawn-something.


    popen() is what I have been looking for. Thank you.

    > Sorry, no. But what Unicode do you mean?  There's UTF-8, and then
    > there are encodings with 16 bits per character and so on.  I'm not
    > familiar with Windows.


    UTF8 works fine, UTF16 is the problem. I believe I will just convert
    UTF-16 to UTF-8.

    Oliver
     
    Oliver Witt, Aug 21, 2008
    #3
    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. Ben Finney
    Replies:
    2
    Views:
    1,028
    Egor Bolonev
    Jun 30, 2003
  2. Egor Bolonev
    Replies:
    0
    Views:
    500
    Egor Bolonev
    Jun 30, 2003
  3. Serge Terekhoff
    Replies:
    0
    Views:
    662
    Serge Terekhoff
    Jun 30, 2003
  4. Replies:
    1
    Views:
    310
  5. Miktor
    Replies:
    7
    Views:
    12,201
    Joe Bacigalupa
    Aug 9, 2005
Loading...

Share This Page