C 意外标记叉()附近的语法错误
但在我看来,这并不是一个语法错误。这不是一个shell脚本,而是CC 意外标记叉()附近的语法错误,c,shell,ubuntu-14.04,C,Shell,Ubuntu 14.04,但在我看来,这并不是一个语法错误。这不是一个shell脚本,而是C 您必须编译它(例如:使用gcc),然后运行创建的可执行文件。如果这样做会发生什么:gcc fork.c&&./a.out?它工作得很好!我试过了。/fork.c因为某种原因:(很抱歉没有提到这一点。我已经用gcc编译了它,但是当我试图运行它时,我得到了语法错误。因此,您正在运行fork或a.out,而不是试图运行fork.c?@giorgoskaragiannopulos:显然您没有,它在您提出的输出中可见:/fork1.c[…
您必须编译它(例如:使用
gcc
),然后运行创建的可执行文件。如果这样做会发生什么:gcc fork.c&&./a.out
?它工作得很好!我试过了。/fork.c因为某种原因:(很抱歉没有提到这一点。我已经用gcc编译了它,但是当我试图运行它时,我得到了语法错误。因此,您正在运行fork
或a.out
,而不是试图运行fork.c
?@giorgoskaragiannopulos:显然您没有,它在您提出的输出中可见:/fork1.c
[…]
#include <stdio.h>
#include <unistd.h>
main()
{
int some_value;
printf("Forking process\n");
fork();
/* This part of the program is executed by two different proceses */
printf("The process id is %d \n", getpid());
some_value = getpid() + 10;
printf("Some value is %d ", some_value);
execl("/bin/ls","/bin/ls","-l",NULL);
/* This line is not executed because of th execl function */
printf("This line is not printed\n");
}
./fork1.c: line 8: syntax error near unexpected token `"Forking process\n"'
./fork1.c: line 8: ` printf("Forking process\n");'