displaying a array to output
Hello to all,
I am trying to display the contents of an array to screen. My problem is with what is going into my array. I am trying to put a sequence of characters into it. I am able to get characters to go into it but, for some reason there not the correct ones??? Below is my source code and the sequence I am trying to put in. I only want the letters to be added.
#include <stdio.h>
#include <string.h>
#include <ctype.h>
main()
{
char test[] = "ORIGIN" ;
char header[100] ;
char sequence[100000] ;
char buffer[10000] ;
char i, c, n, w ;
/* for(n=0 ; n < 999 ; ++n)
{
sequence[n] = 0 ;
{
*/
while(fgets(header, 100, stdin))
{
if(strstr(header, "LOCUS"))
{
int w = 12 ;
while(isblank(header[w]))
{
++w ;
}
printf(">%s", &header[w] ) ;
break ;
}
}
while(fgets(buffer, 10000, stdin))
{
if(strstr(buffer, test)) // start obtaining bases after ORIGIN
{
n = 0 ;
while((c=getchar()) != '/')
switch(c)
{
case 'a': case 'c': case 't': case 'g': case 'u': case 'm': case 'r': case 'w':
case 's': case 'y': case 'k': case 'v': case 'h': case 'd': case 'b': case 'n':
sequence[n] = c ; // put any base character into sequence array
++n ;
break ;
case ' ':
case '\n':
case '\t':
break ; // ignore white space
default:
break ;
}
}
}
printf("%s\n", sequence) ;
return 0 ;
}
SEQUENCE:
1 cctcagatca ctctttggca acgacccctc gycacmataa agataggggg gcaactaaag
61 gaagctctat tagahacagg agcagatgat accatattma aagaaataaa tttgccagga
121 agatggaarc caaaaatgat agggggaatt ggaggtttta tcaaagtaag acagtatgat
181 cagatactca tagaaatctg tggacataaa gttataggta cagtattagt aggacctaca
241 cctgtcaacg taattggaag aaatctgttr actcagattg gttgcacttt aaatttt
//
Any help would be appreciated,
Thank you