dimanche 28 août 2016

Should I reuse variables?

Let's say that i need a counter (I program in C), only once. Should I just reuse a variable that is no longer needed, instead of declaring a counter?

For instance:

int main() {
   int in;

   //code goes here

   for(in=0; in<10; in++)   //do something 
   //instead of using i, I reuse in and use it as a counter

   return 0;
}

Aucun commentaire:

Enregistrer un commentaire