从C程序中调用命令行 [英] Call command line from C program

查看:172
本文介绍了从C程序中调用命令行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

晚上好,大家好!

我很抱歉,如果这听起来像一个愚蠢的问题,但我一直没能找到我要找否则答案。我用C写一个命令行应用程序,并在程序中,我想打电话给其他命令行应用程序。例如(也是唯一一个明显的例子!),说我想编写一个C程序调用Java编译器。其一,我会怎么做呢?有没有直接调用的一些命令行的C函数?两年,我怎么会走正常的文本输出,Java编译器显示,并通过C程序显示呢?

I'm sorry if this sounds like a silly question, but I have not been able to find the answer I am looking for otherwise. I am writing an command line application in C and from within the program, I would like to call other command-line applications. For example (and only as a clear example!), say the I would like to write a C app that calls the java compiler. For one, how would I do this? Is there a C function that directly calls the command line of something? For two, how would I take the normal text output that the java compiler displays and display it through the c program?

我很抱歉,如果这听起来有点疯狂,但我很新的C和我以前从来没有做过这样的事。我很想开始编写一些程序,这些风格的应用程序中。如果它的事项的,我目前运行的是Windows,但如果可能的话将preFER独立于平台的方法,因为我用Linux不时。

I'm sorry if this sounds a bit crazy, but I am very new to C and I have never done anything like this before. I would love to start writing a few of these utility style apps. If it matters any, I am currently running Windows, but would prefer a platform-independent method if possible, as I do use Linux from time to time.

谢谢!

推荐答案

您可能会考虑 系统 。我想你可以在Windows中使用它,以及UNIX / Linux系统。

You might look into system. I think you can use it in Windows as well as UNIX/Linux systems.

这篇关于从C程序中调用命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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