首页 > 解决方案 > 执行不启动程序

问题描述

我有两个程序,其中一个通过 execl 调用另一个,但它没有启动。

这是调用程序:

#include <stdio.h>
#include <unistd.h>
int main(int argc, int *argv[])
{
  printf("Program %s executes", argv[0]);
  execl("hello", " ", "Hello", "World!", NULL);
  return 0;
}

“你好”程序:

#include <stdio.h>
int main(int argc, char *argv[])
{
  int i=1;
  printf("%s\n",argv[0]);
  printf("Program started and got string : ");
  while(argv[i++] != NULL)
   printf("%s ",argv[i]);
  return 0; 
}

标签: cexecl

解决方案


推荐阅读