Hi all,

I had recently met with segmentation fault in my program but i could not figure out why it had occured. Segmentation fault occurs when i am referencing to data that is not there ... So although my program could be compiled, it could not be ran due to segmentation fault ...

Part of my program is as shown below...
================================================
Code:
typedef struct amino{
char seq;
struct amino *before;
struct amino *after;        
}AMINO;

. 
.
.
.
int main (void)
{FILE *data, *output, *output1;
 data = fopen ("Sample.txt", "r");
 output = fopen ("output_sample1.txt","w");
 output1 = fopen ("output_sample2.txt","w");
 char input[100] = {};
 AMINO *ptr;
 AMINO *start; 
 AMINO *start1;
 AMINO *next;
 AMINO *pop;
 AMINO *pop1;
.
. 
.
.
if (start->seq == ' ' || start->seq == '\n')
                              {   fprintf(output,"_");
                                  (AMINO*)pop = (AMINO*)start;
                                  (AMINO*)pop1 = (AMINO*)start->before;
                                   start = (AMINO*)pop1; 
                                   start->after = NULL;
                                   free(pop);
                              }

.
.
.
.
================================================
and the error starts at "start = (AMINO*)pop1;" ...
could anone kindly enlighten me why ?

Thanks so much!!