Interact with console application

O

Oliver Witt

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
 
J

Jorgen Grahn

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
 
O

Oliver Witt

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top