#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include stdlib.h>
#include <string.h>
#define LB_SIZE 1024
int main()(int argc, char *argv[])
{
char full Pathname[] = /usr/X11R6/bin/xeyes;
char *myArgv[LB_SIZE];
myArgv[0] = malloc(strlen(fullPathName) + 1);
strcpy(myArgv[0], fullPathName);
myArgv[1] = NULL;
execvp(fullPathName, myArgv);
exit(0);
}
答案 0 :(得分:2)
字符串应该用引号括起来:
char fullPathname[] = "/usr/X11R6/bin/xeyes";
^ ^
| |
答案 1 :(得分:0)
正如@Als所说,字符串应该用"mystring text"
引号括起来。
我真的认为你需要在编码之前开始学习 C.以下是一些建议: