is there a C++ method of calling an external executable program? I know you
can do it using C, but what about C++? 9 1972
Jon Slaughter wrote: is there a C++ method of calling an external executable program? I know you can do it using C, but what about C++?
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.
V
"Jon Slaughter" <no****@nowhere .com> ha scritto nel messaggio
news:10******** *****@corp.supe rnews.com... is there a C++ method of calling an external executable program? I know
you can do it using C, but what about C++?
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.
Andrea Sini
Jon Slaughter wrote: is there a C++ method of calling an external executable program? I know you can do it using C, but what about C++?
Same way, system().
Brian
"Lemon tree" <le***@tree.i t> wrote in message
news:M4******** **************@ news3.tin.it... "Jon Slaughter" <no****@nowhere .com> ha scritto nel messaggio news:10******** *****@corp.supe rnews.com... is there a C++ method of calling an external executable program? I know you can do it using C, but what about C++?
I think that there is no standard way to do this...
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. So, in my opinion, the best way is to use the C -style
'system()' is as much a part of the C++ standard library as
it is of the C standard library.
possibly wrapped inside a C++ method or something similar.
Why wrap it?
-Mike
Mike Wahler wrote: "Lemon tree" <le***@tree.i t> wrote in message news:M4******** **************@ news3.tin.it... "Jon Slaughter" <no****@nowhere .com> ha scritto nel messaggio I think that there is no standard way to do this...
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.
So, in my opinion, the best way is to use the C -style
'system()' is as much a part of the C++ standard library as it is of the C standard library.
possibly wrapped inside a C++ method or something similar.
Why wrap it?
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.
Regards,
Michiel Salters
"msalters" <Mi************ *@logicacmg.com > wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. . Mike Wahler wrote: "Lemon tree" <le***@tree.i t> wrote in message news:M4******** **************@ news3.tin.it... "Jon Slaughter" <no****@nowhere .com> ha scritto nel messaggio I think that there is no standard way to do this... 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.
So, in my opinion, the best way is to use the C -style
'system()' is as much a part of the C++ standard library as it is of the C standard library.
possibly wrapped inside a C++ method or something similar.
Why wrap it?
Wrap it so you can add arguments more easily;
Huh? 'system()' takes exactly one argument.
the C interface of system has a horrible way to add arguments (memory fiddling).
Huh? 'system()' takes exactly one argument, and it is provided
the same as for any other function. No 'fiddling' needed.
std::string has a decent operator+().
So you want to concatentate strings. You can do this easily for
C-style strings with 'strcat()'.
So even void system( std::string const& ); is a useful wrapper.
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().
-MIke
> is there a C++ method of calling an external executable program? I know you can do it using C, but what about C++?
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):
#include <sstream>
#include <cstdlib>
using std::ostringstr eam;
ostringstream &execute(ostrin gstream &s)
{
std::system(s.s tr().c_str());
return s;
}
ostringstream &operator<<(ost ringstream &s,
ostringstream &(*manip)(ostri ngstream &s))
{
return manip(s);
}
int main() {
ostringstream x;
x << "ls " << execute;
return 0;
}
If you want to see the original code, it's at: http://groups-beta.google.com/group/...940ddf50edf667
I have to admit that until I looked at the date on that post, I hadn't
quite realized how old this really was. :-)
--
Later,
Jerry.
The universe is a figment of its own imagination.
> is there a C++ method of calling an external executable program? I know you can do it using C, but what about C++?
Here's a possibility you might find interesting:
#include <sstream>
#include <cstdlib>
using std::ostringstr eam;
ostringstream &execute(ostrin gstream &s) {
std::system(s.s tr().c_str());
return s;
}
ostringstream &operator<<(ost ringstream &s,
ostringstream &(*manip)(ostri ngstream &s))
{
return manip(s);
}
int main() {
ostringstream x;
x << "ls ";
x << execute;
return 0;
}
This is a quick hack of some much older code that used an strstream; it
might benefit from further work. In case you case, the original code is
here: http://groups-beta.google.com/group/...940ddf50edf667
I must confess that I hadn't realized just HOW old this code was until
I looked at the date on that post...
--
Later,
Jerry.
The universe is a figment of its own imagination.
Okay, I'll make _one_ more try at getting this posted -- as they say,
third time pays for all.... is there a C++ method of calling an external executable program? I know you can do it using C, but what about C++?
Perhaps you'll find this an interesting possibility:
#include <sstream>
#include <cstdlib>
using std::ostringstr eam;
ostringstream &execute(ostrin gstream &s) {
std::system(s.s tr().c_str());
return s;
}
ostringstream &operator<<(ost ringstream &s,
ostringstream &(*manip)(ostri ngstream &s))
{
return manip(s);
}
int main() {
ostringstream x;
x << "ls ";
x << execute;
return 0;
}
--
Later,
Jerry.
The universe is a figment of its own imagination. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: chandan |
last post by:
Is it possible to call an external java program from a trigger in
oracle 8i.
I know that you can call a stored procedure in java from a trigger but
i want to know is it possible to call an external java program
|
by: Sivakumar Shanmugam |
last post by:
Group.. We are running on db2 UDF V8 on Sun solaris platform. I
created an UDF which calles a C-routine(SQL_API_FN). This C-routine in
turn calls an external C-function. The C-function is provided to us by
a vendor(PCMILER application). The C-Function does the following
operations- Open the server,get distance between two points and close
the server. It takes two input parameters(points).
Whenever I call UDF via select statement it always...
|
by: j23 |
last post by:
I have library (static) testlib.cpp:
#include <stdarg.h>
void xxx(...)
{
char buf;
va_list args;
va_start(args, buf);
va_end(args);
}
|
by: RichN |
last post by:
I am developing a c program in Visual Studio .NET 2003. I also have an
Intel(R) Fortran compiler for MVS .NET
My fortran sourcecode already existed. I started a new fortran project and
chose to create a dynamic link library. The beginning of the fortran code
looks like:
SUBROUTINE SFTCK3
!DEC$ ATTRIBUTES DLLEXPORT::SFTCK3
|
by: notregister |
last post by:
How do i call out an external program(e.g. abc.exe) while hiding my current
window form.
when i exit this external program, how do i re-show my window form?
| |
by: utab |
last post by:
Dear all,
I am making a system call to the well known Gnuplot with
system("gnuplot");
gnuplot opens if I only supply this command but I would like to pipe
that command line in my C++ program. For example I want to run a very
simple command like "plot sin(x)". So after running another program,
what is the way to pipe that with some commands from inside the c++
|
by: f rom |
last post by:
----- Forwarded Message ----
From: Josiah Carlson <jcarlson@uci.edu>
To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org
Sent: Monday, December 4, 2006 10:03:28 PM
Subject: Re: 1>make_buildinfo.obj : error LNK2019: unresolved external symbol __imp__RegQueryValueExA@24 referenced in function _make_buildinfo2
Ask on python-list@python.org .
- Josiah
|
by: Maydogg6 |
last post by:
I need a hand with some stubborn link errors.
I'm trying to recreate and old program from 6.0 into .NET, but for some reason when I try to compile I'm getting linking errors for all my function calls that deal with sockets. I've included <winsock2.h> in stdafx.h and I linked to ws2_32.lib by going to project properties->linker->general->additional library directories and typing in ws2_32.lib.
Am I missing some include files or have the...
|
by: Jeff |
last post by:
We have an intranet website that currently uses ActiveX but we need to
make it cross-browser compatible and also get around the problems
we've been having with making it work with IE7 and Vista. We decided
to write an external application to do the work from the client side.
We are not sure how the web page can call the app though with
parameters.
For example, we want to do similar to what the MSDN Library and
Audible are doing with...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |