机制从C main返回一个字符串()程序 [英] Mechanism for returning a string from C main() program

查看:87
本文介绍了机制从C main返回一个字符串()程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,C程序通常与回报,在这里我们返回程序的状态结束。
不过,我想返回一个字符串。其原因是,我会调用从shell脚本中的C-的可执行文件和打印返回的字符串。
是否有同样的机制?

I know that C program generally ends with return, where we return the status of the program. However, I want to return a string. The reason is that, I will be calling the C-executable from a shell script and printing the returned string. Is there any mechanism for the same ?

推荐答案

有没有这样的机制;返回code预计是一个字节。如果你从你的程序要输出字符串,然后使用类似的printf(),并在shell脚本命令替换捕捉到它。

There is no such mechanism; the return code is expected to be a byte. If you want to output a string from your program then use something like printf() and command substitution in the shell script to capture it.

这篇关于机制从C main返回一个字符串()程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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