Question answered... thank you all.

I'm trying to run a for loop on the outside of my function... I can't post the code because its for my semester project which is due on Monday, and I know the code leaches are scouring. So yeah, I'm trying to decrement the char 'S' stored in an array. I basically want the function to repeat until there are less than 11 char 'S' in the array. I'm aware that this is completely wrong (though shamefully I admit to trying... chalk it up to desperation and a nothing to loose attitude), but I'm thinking somewhere along the lines of:

for('S' = 20; 'S' >= 11; --'S')
...function stuff


Yeah, definitely not working. Please help (insert face of despair... and perhaps a tear for added effect).

Thanks a bunch in advance;)

Last edited on
If you decrement the character 'S', the result is 'R'. Do it again and you get 'Q'.
But, I don't think that's what you want to do?

You have some sort of array? Or is it a string? What exactly are you trying to achieve?


...the char 'S' represent sheep in game that I had to program. When there are less than 20 sheep on the board, the game is over. I wanted to run a loop outside of a function that basically says, when there are less than 11 sheep on the board, stop looping because the game is over.

It sounds to me like you need to count the sheep.

You could either maintain a count (an integer) which is incremented every time you add a sheep,and decremented every time you remove a sheep.

Or - perhaps simpler, have a loop which checks every location on the board. Every time an 'S' is found, add 1 to the count. (make sure the count starts at zero)., yeah, I don't know why I didn't think of that at first. As soon as I emailed you I felt like an idiot because I thought, "why am I not just counting the damn sheep?" Probably a good sign that I need to step away for a minute, lol. Thank you so much for taking the time to answer my questions;)
No problem - sometimes taking a break is the best way to make progress.
Topic archived. No new replies allowed.