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 に答える