寻找功能 [英] looking for function

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

问题描述

我不是学生,正在寻找功课帮助。


我正在寻找能够执行系统功能的交流功能

将输出返回到字符串中。我不想使用文件作为媒介。

管道到文件,读取文件并返回conntents。我宁愿避免使用

文件IO。


char * dump;

dump = ex_system(" / bin / ls / home / me");


char * ex_system(char * ex)

{

char buf [very_big];

//设置一些管道和叉子

//在buf中捕获stdout / stderr

exec($ ex);

返回buf;

}

___ _ ____ ___ __ __

/ _)(_)/ / _ __ / _ \ ___ _ / / _ / / ____ ___

/ _ / / / / // / / ___ / _` / __ / __ / _ \ / _ \

/ ____ / _ / _ / _ / \ _,/ / _ / \ _,_ / \ __ / \ __ / \ ___ / _ // _ /

/ ___ /

Texas Instruments ASIC电路设计Methodlogy Group

德克萨斯州达拉斯,214-480-4455, b - ****** @ ti.com

I''m not student, looking for homework help.

I''m looking for a c function that will execute a system function then
return the output into a string. I don''t want to use a file as a medium.
pipe to file , read file and return conntents. I would rather avoid the
file IO.

char* dump;
dump = ex_system("/bin/ls /home/me");

char* ex_system(char* ex)
{
char buf[very_big];
//setup some pipes and fork
//to capture stdout/stderr in buf
exec($ex);
return buf;
}
___ _ ____ ___ __ __
/ _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
/ _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
/___/
Texas Instruments ASIC Circuit Design Methodlogy Group
Dallas, Texas, 214-480-4455, b-******@ti.com

推荐答案

ex);

返回buf;

}

___ _ ____ ___ __ __

/ _)(_)/ / _ __ / _ \ ___ _ / / _ / / ____ ___

/ _ / / / / // / / ___ / _` / __ / __ / _ \ / _ \

/ ____ / _ / _ / _ / \ _,/ / _ / \ _,_ / \ __ / \ __ / \ ___ / _ // _ /

/ ___ /

德州仪器(TI)ASIC电路设计方法集团

德克萨斯州达拉斯市,214-480-4455, b- ******@ti.com
ex);
return buf;
}
___ _ ____ ___ __ __
/ _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
/ _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
/___/
Texas Instruments ASIC Circuit Design Methodlogy Group
Dallas, Texas, 214-480-4455, b-******@ti.com


Billy Patton< bp ***** @ bright.dal.design.ti.com>写道:
Billy Patton <bp*****@bright.dal.design.ti.com> writes:
我正在寻找一个执行系统功能的c函数然后将输出返回到字符串中。我不想使用文件作为媒介。
管道到文件,读取文件和返回conntents。我宁愿避免使用
文件IO。
I''m looking for a c function that will execute a system function then
return the output into a string. I don''t want to use a file as a medium.
pipe to file , read file and return conntents. I would rather avoid the
file IO.




C没有这样的功能。

-

对于那些想要将C翻译成Pascal的人来说,可能需要更好地进行切除术。

可以满足您的需求。 --M。 Ambuhl


以下是创建C-to-Turbo-Pascal翻译器的步骤...... - H。 Schildt



C doesn''t have such a function.
--
"For those who want to translate C to Pascal, it may be that a lobotomy
serves your needs better." --M. Ambuhl

"Here are the steps to create a C-to-Turbo-Pascal translator..." --H. Schildt


Billy Patton写道:
Billy Patton wrote:
我正在寻找将执行系统功能的交流功能
将输出返回到字符串中。


标准C中没有这样的功能。您的系统可能有这样一个

库函数,因此您可以在新闻组中询问您的系统,如果

你不需要你的程序可移植。

我不想用文件作为媒介。管道到文件,读取文件和
返回conntents。我宁愿避免文件IO。
I''m looking for a c function that will execute a system function then
return the output into a string.
There is no such function in Standard C. Your system may have such a
library function, so you could ask on a newsgroup for your system, if
you don''t need your program to be portable.
I don''t want to use a file as a medium. pipe to file , read file and
return conntents. I would rather avoid the file IO.




嗯,它涉及文件IO,但一个相当常见的功能是popen()

函数。也许你的系统有这个。你运行一个命令,

输出通过管道传输到C FILE *你可以fread()或其他什么然后

pclose()。这样,至少你不需要在

文件系统中创建一个文件,然后将其删除。


-

Hallvard



Well, it involves file IO, but one fairly common function is the popen()
function. Maybe your system has that. You run a command, and the
output is piped to a C FILE* which you can fread() or whatever and then
pclose(). That way, at least you don''t need to create a file in the
file system and delete it afterwards.

--
Hallvard


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

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