0

我的代码中有一个奇怪的地方有段错误。它在最后一个 if 语句中。任何人都知道我为什么会出现段错误?

void processArgument(char argument[]){
    FILE *sketcher;
    FILE *fp;
    fp = fopen (argument, "r");
    sketcher = popen(Exec_c, "w");
 if (fp == NULL){
        printf ("Could not open pipe to %s\n", argument);
  exit (EXIT_FAILURE);
 }
    if (sketcher == NULL){
        printf ("Could not open pipe to %s\n", argument);
  exit (EXIT_FAILURE);
    }else{
        parseFile(fp, sketcher);
        if(fclose(fp)==EOF){
   printf("couldn't close pipe to %s.\n", argument);
   exit(EXIT_FAILURE);
  }
        if (pclose(sketcher) == -1){                                                 //if (pclose(sketcher) == -1){
            fprintf(stderr, "draw_line error: couldn't close pipe to %s.\n", Exec_c);//fprintf(stderr,"",E);
            exit(EXIT_FAILURE);    
        }
    }
} 
4

1 回答 1

3

最简单的可能性是它Exec_c不是一个有效的字符串。

于 2010-11-13T19:26:30.447 回答