2015-01-11 2 views
0

у меня есть проблема, когда я пытаюсь построить код в Xcode друзей, IAM в Noobie на C, мне нужна помощьАнализировать выпуск ожидается программа заявление 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) 

У меня есть вопрос синтаксического анализа ожидается заявление любой может сказать мне, почему его WR Онг? Спасибо.

+2

Ну, синтаксический анализатор ожидается заявление и не было ни одного ... Если вы не» t хочу что-либо добавить; после если. – tux3

ответ

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) {} 
Смежные вопросы