【发布时间】:2012-06-21 17:17:44
【问题描述】:
我在 C 程序中使用 system() 函数来获取字符串。但 system() 函数实际上显示输出并返回一个整数值(成功执行时为 0)。但我想要的是 system() 函数的输出必须存储到字符串变量中。例如:
char a[5];
a = system("echo \"hi\"");
printf("The string is: %s",a);
这种a存储值hi输出为The string is: hi的东西
请帮忙。提前致谢。运行平台:Linux
【问题讨论】: