【发布时间】:2020-11-03 01:32:31
【问题描述】:
这是我们教授给我们的 execl() 示例。一个文件夹里有2个文件,com1.c的样子
#include <stdio.h>
#include <unistd.h>
int main(){
printf("hello...");
fflush(stdout);
execlp("com2","com2",(char*)NULL);
perror("err at execl");
return 1;
}
com2.c 看起来像
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
int main(){
write(1, "...you unicorn ;)",13);
return 0;
}
在运行时它给了我这个消息:
hello...err at execl: No such file or directory
我怎样才能得到“你好......你独角兽;” ? 期待感谢。
【问题讨论】:
-
您是否构建了一个名为
com2的可执行文件并将其放在 PATH 中的目录中?