Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Interact with console application

Reply
Thread Tools

Interact with console application

 
 
Oliver Witt
Guest
Posts: n/a
 
      08-21-2008
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
 
Reply With Quote
 
 
 
 
Jorgen Grahn
Guest
Posts: n/a
 
      08-21-2008
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!
 
Reply With Quote
 
 
 
 
Oliver Witt
Guest
Posts: n/a
 
      08-21-2008
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Starting a GUI application out of an console application Fabian Steiner Python 1 07-17-2006 05:01 PM
A simple Console Application to ASP.NET application Web learner ASP .Net 1 01-27-2006 03:09 AM
How to start ASP.Net application from console application? Mike ASP .Net 9 11-30-2005 12:26 AM
interact with application installer prompts using Python rtilley@vt.edu Python 1 11-22-2005 07:02 PM
Re: console mp3->wav decoder for $indows or GUI one which supports console Ben Finney Python 2 06-30-2003 05:43 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57