Jon Slaughter wrote:[color=blue]
> is there a C++ method of calling an external executable program? I know you
> can do it using C, but what about C++?[/color]
Use the same way you know. C++ is often quite compatible with C in that
area. If you encounter a problem, come back and let's talk about it.
"Jon Slaughter" <nobody@nowhere .com> ha scritto nel messaggio
news:10rrvqecbt ia878@corp.supe rnews.com...[color=blue]
> is there a C++ method of calling an external executable program? I know[/color]
you[color=blue]
> can do it using C, but what about C++?[/color]
I think that there is no standard way to do this...
So, in my opinion, the best way is to use the C -stylepossibly wrapped
inside a C++ method or something similar.
Jon Slaughter wrote:
[color=blue]
> is there a C++ method of calling an external executable program? I
> know you can do it using C, but what about C++?[/color]
"Lemon tree" <lemon@tree.i t> wrote in message
news:M4ovd.2898 60$b5.14124045@ news3.tin.it...[color=blue]
> "Jon Slaughter" <nobody@nowhere .com> ha scritto nel messaggio
> news:10rrvqecbt ia878@corp.supe rnews.com...[color=green]
> > is there a C++ method of calling an external executable program? I know[/color]
> you[color=green]
> > can do it using C, but what about C++?[/color]
>
> I think that there is no standard way to do this...[/color]
Yes there is. Standard function 'system()'. But note
that its argument and actual functionality are implementation-
specific (e.g. not all implementations have the necessary access
to a command processor.
[color=blue]
>
> So, in my opinion, the best way is to use the C -style[/color]
'system()' is as much a part of the C++ standard library as
it is of the C standard library.
[color=blue]
>possibly wrapped
> inside a C++ method or something similar.[/color]
Mike Wahler wrote:[color=blue]
> "Lemon tree" <lemon@tree.i t> wrote in message
> news:M4ovd.2898 60$b5.14124045@ news3.tin.it...[color=green]
> > "Jon Slaughter" <nobody@nowhere .com> ha scritto nel messaggio
> > I think that there is no standard way to do this...[/color]
>
> Yes there is. Standard function 'system()'. But note
> that its argument and actual functionality are implementation-
> specific (e.g. not all implementations have the necessary access
> to a command processor.
>[color=green]
> >
> > So, in my opinion, the best way is to use the C -style[/color]
>
> 'system()' is as much a part of the C++ standard library as
> it is of the C standard library.
>[color=green]
> >possibly wrapped
> > inside a C++ method or something similar.[/color]
>
> Why wrap it?[/color]
Wrap it so you can add arguments more easily; the C interface
of system has a horrible way to add arguments (memory fiddling).
std::string has a decent operator+(). So even
void system( std::string const& );
is a useful wrapper.
"msalters" <Michiel.Salter s@logicacmg.com > wrote in message
news:1103023866 .888986.162720@ z14g2000cwz.goo glegroups.com.. .[color=blue]
>
> Mike Wahler wrote:[color=green]
> > "Lemon tree" <lemon@tree.i t> wrote in message
> > news:M4ovd.2898 60$b5.14124045@ news3.tin.it...[color=darkred]
> > > "Jon Slaughter" <nobody@nowhere .com> ha scritto nel messaggio
> > > I think that there is no standard way to do this...[/color]
> >
> > Yes there is. Standard function 'system()'. But note
> > that its argument and actual functionality are implementation-
> > specific (e.g. not all implementations have the necessary access
> > to a command processor.
> >[color=darkred]
> > >
> > > So, in my opinion, the best way is to use the C -style[/color]
> >
> > 'system()' is as much a part of the C++ standard library as
> > it is of the C standard library.
> >[color=darkred]
> > >possibly wrapped
> > > inside a C++ method or something similar.[/color]
> >
> > Why wrap it?[/color]
>
> Wrap it so you can add arguments more easily;[/color]
Huh? 'system()' takes exactly one argument.
[color=blue]
> the C interface
> of system has a horrible way to add arguments (memory fiddling).[/color]
Huh? 'system()' takes exactly one argument, and it is provided
the same as for any other function. No 'fiddling' needed.
[color=blue]
> std::string has a decent operator+().[/color]
So you want to concatentate strings. You can do this easily for
C-style strings with 'strcat()'.
[color=blue]
> So even
> void system( std::string const& );
> is a useful wrapper.[/color]
It would let you pass a std::string object, yes. How useful
that might be is imo a matter of opinion. One can already
supply the contents of a std::string to 'system()' via
std::string::c_ str().
> is there a C++ method of calling an external executable program?[color=blue]
> I know you can do it using C, but what about C++?[/color]
Here's one possibility you might find interesting (this was a quick
hack at overhauling some code I wrote _years_ ago that used an
ostrstream, so it might benefit from some cleanup):
Okay, I'll make _one_ more try at getting this posted -- as they say,
third time pays for all....
[color=blue]
> is there a C++ method of calling an external executable program?
> I know you can do it using C, but what about C++?[/color]
Perhaps you'll find this an interesting possibility:
Comment