Hello to all,
I am having difficulty trying to build a large string (approx 5 million characters) from a large input file (approx. 11 MB). The program compiles fine, it just doesn't stop running. Here is my code:
Code:
main( int argc, char **argv )
{
FILE *input ;
FILE *output ;
char buffer[1000] ;
int i = 0 ;
char c ;
char *seqData ;
seqData = (char *)malloc(10000000) ;
/* char t1, t2, t3, t4 ;
int index ;
int tupleCount[4][4][4][4] ; */
if( ! ( input = fopen( argv[1], "r" ) ) )
{
printf( "COULD NOT OPEN FILE %s - Exit!\n", argv[1]) ;
exit(1) ;
}
while(fgets(buffer, 1000, input))
{
// start obtaining bases after ORIGIN
if(strstr(buffer, "ORIGIN"))
{
int i = 0 ;
while((c=getchar()) != '/')
{
if(c >= 'a' && c <= 'z')
{
seqData[i++] = c ;
}
}
}
}
/*for( index = 0 ; index < strlen(seqData) - 3 ; ++index )
{
t1 = seqData[index] ;
t2 = seqData[index + 1] ;
t3 = seqData[index + 2] ;
t4 = seqData[index + 3] ;
count the different 4-mers
}*/
printf("Here is the sequence:\n" ) ;
return(0) ;
}
Any help would be great. Please keep in mind that I am a newbie to programming.