【发布时间】:2018-01-10 02:32:55
【问题描述】:
我写了以下内容:
#include <stdlib.h>
#include <stdio.h>
void ExecAsRoot (char* str);
int main ()
{
printf ("Host real ip is:");
ExecAsRoot("ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/'");
return 0;
}
void ExecAsRoot (char* str) {
system (str);
}
我的预期输出是:
Host real ip is:7.17.11.29
而实际输出是:
7.17.11.29
Host real ip is:
这是为什么?
【问题讨论】: