Possible Duplicate:
What is the function to replace string in C?
I'm designing a game in C and I've set up my "board" with a 10x10 2D array filled with characters. There are only four characters in the board, and they've been randomly generated.
Anyone got an idea of how to search for a 3 in a row within say board[1]?
Row 0: a b b b c d a a c d
So there's a match of 'bbb' in there. How do traverse my search in such a way that I get to remove all 'b's, switch them to spaces, and then add them up to a score?
The result would look like this: (' ' is the replacement)
Row 0: a c d a a c d
And after that, I also need to check for lines of 4 and 5. Any help would be appreciated. :)
EDIT: Adding a sample of how i'm trying to solve this.
char c[10][10];
int start; //where i would start deleting
int end; //where i would stop deleting from the rows/columns
//REMOVE LINES OF 3/4/5
for(i = 0; i < 10; i++) { //BY ROWS
tempChar = c[i][0];
start = 0;
for(j = 1; j < 10; j++) { //EACH ELEMENT IN THE ROW
if(tempChar == c[i][j] && tempChar != ' ') {
counter++; //found one more next to it
end = j; //end of the 3/4/5 in a row
}
}
}