用C ++调用另一个程序并指导程序流程 [英] Calling another program in C++ and directing the program flow

查看:70
本文介绍了用C ++调用另一个程序并指导程序流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,


我正在使用


system(gnuplot)系统调用着名的Gnuplot;

如果我只提供这个命令,那么
gnuplot会打开,但我想在我的C ++程序中管道这个命令行。例如,我想运行一个非常简单的命令,例如plot sin(x)。所以在运行另一个程序之后,

用c ++

程序中的一些命令管道的方法是什么。


或者我应该在Gnuplot论坛中问这个问题吗?


提前回复Thx。

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++
program.

Or should I ask this in Gnuplot forums?

Thx for the replies in advance.

推荐答案

utab写道:
utab wrote:
亲爱的,

我正在系统调用着名的Gnuplot与

系统(gnuplot);

如果我只提供此命令,gnuplot会打开,但我想在我的C ++程序中管理该命令行。例如,我想运行一个非常简单的命令,如plot sin(x)。因此在运行另一个程序之后,使用c ++
程序中的一些命令来管理它的方法是什么。


system()应该将给定的命令行提供给系统的shell

如果可能的话。所以你想要执行的命令应该像你在shell中输入的那样给予
system()。

或者我应该在Gnuplot论坛中问这个吗?
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++
program.
system() is supposed to supply the given command line to the system''s shell
if possible. So the command that you want to execute should be given to
system() just like you would type it in the shell.
Or should I ask this in Gnuplot forums?




这不是特定于gnuplot的,所以没有。



This is not gnuplot specific, so no.


喜欢这个


系统(gnuplot plot sin(x));


编译


但是会出错:


sh:-c:第0行:意外令牌附近的语法错误`(''

sh:-c:第0行:`gnuplot plot sin (x)''

like this

system("gnuplot plot sin(x)");

compiles

but gives errors:

sh: -c: line 0: syntax error near unexpected token `(''
sh: -c: line 0: `gnuplot plot sin(x)''


utab写道:
utab wrote:
喜欢这个

系统(gnuplot plot sin(x));

编译

但是会出错:

sh:-c:第0行:意外令牌附近的语法错误`(''
sh:-c:第0行:'gnuplot plot sin(x)''
like this

system("gnuplot plot sin(x)");

compiles

but gives errors:

sh: -c: line 0: syntax error near unexpected token `(''
sh: -c: line 0: `gnuplot plot sin(x)''




你的shell解释了''(''以你不想要的方式。如果
你输入


gnuplot plot sin(x)


直接进入你的shell?我猜是一样的。找出正确的

命令行必须是什么样的。



Your shell interprets the ''('' in a way that you don''t want. What happens if
you enter

gnuplot plot sin(x)

directly into your shell? I''d guess the same. Find out what the correct
command line has to look like.


这篇关于用C ++调用另一个程序并指导程序流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆