I have quite a lot of experience programming, but over the years of constantly writing functions, I just wanted to know the communities opinion on this matter is.
Under a function is the best place to declare all the variables be at the very beginning or declaring them as you go?
So for example:
void fake_function1() {
int i;
//do something here with variable i
int counter;
//do something here with variable counter
}
or
void fake_function2() {
int i;
int counter;
//do something here with variable i
//do something here with variable counter
}
As of now I tend to usually do things like in fake_function2() since that seems more correct, but some other times I would do things like in fake_function1() since it looks more readable and readable code is always better code especially when code can run over 100k lines easily in my opinion. I think consistency is very important, but I am having a hard time deciding which is better.