shell_command(char gcommand[100]) {
FILE *pipe = popen("ls", "r");
char output[100];
if ( pipe ) {
fgets(output, sizeof output, pipe);
pclose(pipe);
}
return output;
}
Run Code Online (Sandbox Code Playgroud)
结果是
program.c:在函数'shell_command'中:
program.c:42:warning:return从指针生成整数而没有
强制转换program.c:42:warning:function返回局部变量的地址
我两天都用Google搜索,但没有成功