且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何调用外部程序?

更新时间:2023-12-05 20:18:52

2003年12月13日星期六22:48:28 -0500,Sanyi Benczik写道:
On Sat, 13 Dec 2003 22:48:28 -0500, Sanyi Benczik wrote:
C ++中是否有标准的方式来调用外部程序,或者这是
平台依赖?

如果它依赖于平台,有人可以放弃使用什么或者在RedHat上查找GNU C ++信息的位置?我正在进行一些数值计算,需要调用外部绘图程序(gnuplot)
并返回数字。
Is there a standard way in C++ to call an external program or is this
platform dependent?

If it is platform dependent, can somebody drop a line what to use or
where to look for info for GNU C++ on RedHat? I am doing some numerical
calculations and need to invoke an external plotting program (gnuplot)
and return to the numerics.




我不喜欢我不知道这与平台无关,但是< stdio.h>包含:

FILE * popen(const char *命令,const char *类型);

这允许您打开一个程序并读取stdin(r)或者以与fopen相同的方式写出stdout

(w)。


可能有更好的解决方案,但这是第一件事来了

想到。


-Brian



I don''t know how platform independent this is, but <stdio.h> contains:
FILE *popen(const char *command, const char *type);
This allows you to open a program and either read stdin ("r") or write stdout
("w") in the same manner as fopen.

There is probably a better solution, but this is the first thing that came
to mind.

-Brian


man system 3


Sanyi Benczik写道:
man system 3

Sanyi Benczik wrote:
C ++中是否有标准的方式来调用外部程序或者这个平台是否依赖?

如果它是依赖于平台的,有人可以放弃使用什么或者在RedHat上查找GNU C ++的信息?我正在做一些数值计算,需要调用一个外部绘图程序(gnuplot)
并返回数字。

如果我发布了两次,我很抱歉。
Sanyi
Is there a standard way in C++ to call an external program or is this
platform dependent?

If it is platform dependent, can somebody drop a line what to use or
where to look for info for GNU C++ on RedHat? I am doing some numerical
calculations and need to invoke an external plotting program (gnuplot)
and return to the numerics.

Sorry if I posted twice.

Thanks,
Sanyi






Sanyi Benczik< sb ****** @ vt.edu>在消息新闻中写道:< br ********** @ solaris.cc.vt.edu> ...
Sanyi Benczik <sb******@vt.edu> wrote in message news:<br**********@solaris.cc.vt.edu>...
C ++中是否有标准的方式来调用外部程序或者这个平台是否依赖?

如果它依赖于平台,有人可以放弃使用什么或者在RedHat上查找GNU C ++信息的位置?我正在做一些数值计算,需要调用一个外部绘图程序(gnuplot)
并返回数字。

如果我发布了两次,我很抱歉。
三义
Is there a standard way in C++ to call an external program or is this
platform dependent?

If it is platform dependent, can somebody drop a line what to use or
where to look for info for GNU C++ on RedHat? I am doing some numerical
calculations and need to invoke an external plotting program (gnuplot)
and return to the numerics.

Sorry if I posted twice.

Thanks,
Sanyi




我不确定,但也许System(char *)可能看起来很有帮助......那么你

可以将输出传输到您的程序或其他东西。



I am not sure, but maybe System(char *) might seem helpful... Then you
can pipe the output to your program or something.