I've for a while been in the habit of using size_t for my loop counters like this:
My reasoning behind this is that many of the critical std lib functions like malloc, memcpy, and so on take size_t, and strlen() returns size_t.Code:size_t i; for(i = 0; i < 500; i++) { //do stuff }
My other big reason is that logically, when I think of my counter, I think of it being a number 0 or greater. I never employ counters which need to have negative numbers.
Is this practice of mine good? Why or why not? What type do you typically use for your counters? If all else fails, assume we're talking about situations where the counter is being compared with a integer in the set 0 to 64 bit max.