::please help with recursion::

This is a discussion on ::please help with recursion:: within the C++ Programming forums, part of the General Programming Boards category; I know there are a lot of people with enough experience to help figure out how to debug the last ...

::please help with recursion::

I know there are a lot of people with enough experience to help figure out how to debug the last problem with my program.
the problem is when you enter the starting coordinates as shown it can't fill in the whole "image" leaving out a small portion. Does anyone have any suggestions on how to get this program to function with any starting point without leaving out anything?
Also this was one of my first attempts at writing a recursive program so any advice would be appreciated.

Seems to me that if you want a fool-proof filling algorhythm you'd be better off with one recursing function that goes in 4 directions, rather than 4 functions that each go in 2 directions. That would give a much easier to read program as well.
It would result in an ungodly amount of recursions for a sizable image though, so you'll probably have to take a bit of a smarter approach. (for example having one call to the function fill a whole horizontal line as opposed to just one pixel; filling a horizontal line could be done with a while-loop instead of recursion)
Another thing, rather than checking for whether a byte is filled with 'X', it might be better if you instead check whether it's NOT filled with '.' or even better: whatever the value of your starting byte was. (you could pass this as an argument of the recursive function as well)
That way you could fill any area of one value.

basically, it's drawing itself into a box and doesn't know to get out of it... if you watch closely, you'll see that it blocks itself off. the algorithm is working right, just not the way you expected.

edit: you may need to change "clear" at the top to "cls" if you're using windows
edit2: if you're using this for any production-level thing, I'd find a replacement for the wait() and clearScreen() functions I've provided - the wait() function eats up processor time, and clearScreen() uses some possibly dangerous code.

Thank you both Boksha and major_small for taking the time to look at my code and give me some advice. If this wasn't an exercise just to practice recursion I would probably prefer to use loops just to fill it in instead of so many recursive calls but I wanted to try my hand at using recursion and I can see where I need to improve Thank you major_small for providing that last example of code it was really helpful in teaching me some tricks on slowing down the recursion so i could examine how it was working that was something i wished i had known before how to implement for debugging also your code was what i had in mind at first in order to solve the problem but I missed some little things when i first wrote it and then my version that i posted was what I had to resort to in order to get it functioning correctly. I am right now studying your code to see where the n00b problem is because I hope that it will help me with debugging in the future. But I hope that if i can't see it you wouldn't mind maybe giving me a hint. Also since I don't know much about threads maybe you could explain a little about how they would help implement the areaFill function?

edit: oh just figured out that your draw() function was accessing past the array elements, fixed that and it works like a charm, cheers