Thanks Adak, that was indeed what I was trying to do.
Yes, I really should have removed that comment..
Would it be possible to ask why you set up the for loop like that and what tmp2 does, please?
--dave
Thanks Adak, that was indeed what I was trying to do.
Yes, I really should have removed that comment..
Would it be possible to ask why you set up the for loop like that and what tmp2 does, please?
--dave
Sure! Go ahead and ask!
Just messing with ya!
That's just the standard way to walk through an array, decrimenting. Tmp2 is just a placeholder. We need that value before we can start the next line of code. I suppose you could do something with parentheses, but the simpler your code logic is, (generally), the better.
Cheers for that.
Is there any way this can get itself stuck in an infinite loop, since that is what has happened when I put it into my main (embedded) application.
--dave
Did you note that I changed the name of the array in my example?
(I dislike long array names).
Do you need to keep this char array as just char's and not add the end of string char to the end of it? Doing so would elevate it to a string, and then the standard string to number functions could be used.
Post up your code that shows the endless loop, and I'll see what's up with it.
Hi Adak,
I have solved it myself, here is the code which worked (I did remember to change the name of the array - I have a few arrays in my code (as you have probably realised, this is a small module) and it helps me to see which one is which.
My compiler didn't like using i as a loop control parameter (the compiler is an ARM Cortex M3 compiler from Raisonance), it just never exited the loop and made hourCount invalid when i went undefined.Code:for(lc_count = 0;lc_count < 5; lc_count++) { hour_tmp = hours_array[i] - '0'; hour_tmp *= array_mult; hourCount = hourCount + hour_tmp; array_mult *= 10; --i; }
Thanks again for all your help
--dave