hello all, I'm trying to compare a user selected number of characters to an array which holds 500000 characters. Basically the user selects a window size, anywhere from 1 to whatever, now I have to look into the array that holds the 500000 characters, and pick a random starting position so lets say that:
window=4 and my random starting number is 48, so I take the characters in my textArray from textArray[48] to textArray[51], and put these 4 characters into a seperate array. The next thing I have to do is to again, step through the array of 500000 characters looking for the exact same combinations of 4 characters just taken out, and getting plus counting the character that appears right after it.
this is what I have so far:
any help?Code:void generateOutput(char text[], int window, int length, int sum) { //declaring arrays //keep in mind that window size was inputed correctly char *windowArr = new char[window]; //window array //declaring variables int randomPosition = rand(); //there is a function that I do not include that replaces this //and limits the random position to be [0, 500000] int i, j; int count = 0; for( i=0; i<window; i++){ windowArr[i] = text[randomPosition + i]; } //compare the window /*THE PROBLEM IS IN THE NEXT PART, ANYTHING I DO IS LIKE HARD CODING*/ int count = 1; for( i=0; i<500000; i++){ if( windowArr[0] == text[i]){ //text is array with 500000 characters for( j=1; j<window; j++){ if( windowArr[j] == text[i+1] ){ count++; if( (count != window) && (windowArr[j+1] = text[i+2]) ){ cout++; }else{break;} }else{break;} } }else{break;} } //AND so on, this is nothing else but hardcoding...I've tried many different ways and comout with similar result....
thanks,
axon
}



LinkBack URL
About LinkBacks


