Code:
thanks vart and QuestionC... below is my complete prog ... thanks so much
===========================
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<strings.h>
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;
while (fgets(input,100,data)!= NULL)
{ if (strstr(input, "SQ SEQUENCE " ) != NULL)
{ fprintf (output, "=================================\n");
start = malloc (sizeof (AMINO));
start1 = start;
start->before = NULL;
start->after = NULL;
while ( (start->seq = fgetc (data)) != '/')
{ fprintf (output, "%c", start->seq);
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);
}
next = malloc (sizeof(AMINO));
start->after = next;
next->before = start;
start = next;
start->after = NULL;
}
ptr = start1;
while(ptr->after != NULL)
{fprintf (output1, "%c", ptr->seq);
ptr = ptr->after;
}
fprintf(output1, "\n==============================\n");
free (start1);
}
}
fclose (data);
fclose (output);
fclose (output1);
return EXIT_SUCCESS;
}
============================