如何实现运行功能? [英] How do I implement a run function ?

查看:92
本文介绍了如何实现运行功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写C代码,用于基于LINUX的系统创建菜单,而不是需要输入长命令的命令提示符。它在当前工作目录中打印我们的目录和文件。 switch case中的'r'命令应该运行一个可执行文件。系统将提示用户输入文件的编号或要执行的给定列表中的名称,但我不知道用于实现它的命令。



我尝试了什么:



我尝试过使用system()但是没有帮助。

I am writing C code is for LINUX based system to create a menu instead of a command prompt that requires long commands to be typed. It prints our directories and files in the current working directory. The 'r' command in the switch case should run an executable file. The user will be prompted to enter the number for the file or the name from the given list to be executed but I am not aware as to what commands to use to implement it.

What I have tried:

I have tried use system() but that has not helped.

推荐答案

'没有帮助'并没有真正告诉我们为什么不/你正在寻找什么 - 你可以尝试这里概述的exec_prog()函数如何使用参数在linux中的C代码中执行外部程序? - 堆栈溢出 [ ^ ]



..因为你不想说你是否想要输出捕获的例子,它有点难以提供更多的帮助(帮助的质量与要求/质量的质量成正比)
'has not helped' doesnt really tell us why not/what you're looking for - you could try the exec_prog() function outlined here How do I execute external program within C code in linux with arguments? - Stack Overflow[^]

.. since you dont say whether you want the output captured for example, its a bit hard to offer more help (the quality of help is in direct proportion to the quality of the requirements/question)


这篇关于如何实现运行功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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