请看一下这段代码:
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
int main() {
FILE *process_fp = popen("make -f -", "w");
if (process_fp == NULL) {
printf("[ERR] make not found!\n");
} else {
char txt[1024] = "all:\n\t@echo Hello World!\n";
fwrite(txt, sizeof(char), strlen(txt), process_fp);
pclose(process_fp);
}
}
该程序将打印“Hello World!”。它在 Linux 平台上工作,但在Solaris上失败,它抱怨:make: *** fopen (temporary file): No such file or directory. Stop.
.
我怎么解决这个问题?