Something like this (yes, this doesn't deal with some edge cases - that's not the point):
int CountDigits(int num) { int count = 1; while (num >= 10) { count++; num /= 10; } return count; }
What's your opinion about this? That is, using function arguments as local variables.
Both are placed on the stack, and pretty much identical performance wise, I'm wondering about the best-practices aspects of this.
I feel like an idiot when I add an additional and quite redundant line to that function consisting of int numCopy = num, however it does bug me.
What do you think? Should this be avoided?