解析问题预期语句 C 程序
Parse issue expected statement C program
我尝试在 Xcode 中构建代码时遇到问题
朋友们,我是C的菜鸟,我需要一些帮助
这是我的 main.c 文件
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
int main (int argc, char *argv[])
{
pid_t pid;
int status;
if (argc < 2) {
printf ("Something goes wrong!\n");
return 1;
}
for (;;) {
pid = fork ();
if (pid == -1) {
perror ("fork");
exit (1);
}
if (pid == 0) {
execvp (argv[1], &argv[1]);
} else {
wait (&status);
if (WIFEXITED (status))
{
printf ("%s exited with return code %d\n",
argv[1], WEXITSTATUS (status));
if (WEXITSTATUS (status) != 0)
}
else if (WIFSIGNALED(status))
{
printf ("%s terminated by signal number %d\n",
argv[1], WTERMSIG (status));
}
/* we want to give time to user for read output of program */
sleep (1);
}
}
return 0;
}
这一行之后
if (WEXITSTATUS (status) != 0)
我有一个解析问题预期语句
谁能告诉我为什么错了?
谢谢。
只需更改此
printf ("%s exited with return code %d\n",
argv[1], WEXITSTATUS (status));
if (WEXITSTATUS (status) != 0)
至此
printf ("%s exited with return code %d\n",
argv[1], WEXITSTATUS (status));
if (WEXITSTATUS (status) != 0);
或
printf ("%s exited with return code %d\n",
argv[1], WEXITSTATUS (status));
if (WEXITSTATUS (status) != 0) {}
我尝试在 Xcode 中构建代码时遇到问题 朋友们,我是C的菜鸟,我需要一些帮助
这是我的 main.c 文件
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
int main (int argc, char *argv[])
{
pid_t pid;
int status;
if (argc < 2) {
printf ("Something goes wrong!\n");
return 1;
}
for (;;) {
pid = fork ();
if (pid == -1) {
perror ("fork");
exit (1);
}
if (pid == 0) {
execvp (argv[1], &argv[1]);
} else {
wait (&status);
if (WIFEXITED (status))
{
printf ("%s exited with return code %d\n",
argv[1], WEXITSTATUS (status));
if (WEXITSTATUS (status) != 0)
}
else if (WIFSIGNALED(status))
{
printf ("%s terminated by signal number %d\n",
argv[1], WTERMSIG (status));
}
/* we want to give time to user for read output of program */
sleep (1);
}
}
return 0;
}
这一行之后
if (WEXITSTATUS (status) != 0)
我有一个解析问题预期语句 谁能告诉我为什么错了? 谢谢。
只需更改此
printf ("%s exited with return code %d\n",
argv[1], WEXITSTATUS (status));
if (WEXITSTATUS (status) != 0)
至此
printf ("%s exited with return code %d\n",
argv[1], WEXITSTATUS (status));
if (WEXITSTATUS (status) != 0);
或
printf ("%s exited with return code %d\n",
argv[1], WEXITSTATUS (status));
if (WEXITSTATUS (status) != 0) {}