Unreferenced variable

An unreferenced variable in the source code of a computer program is a variable that is defined but which is never used. This may result in a harmless waste of memory (unless the compiler used detects the situation and does not allocate storage for the variable, perhaps also issuing a warning). Some coding guideline documents consider an unreferenced variable to be a symptom of a potential coding fault.

Examples

C:

 int main(void)
 {
   int i, j;
   for (i=0; i<10; i++)
      printf("%d", i);
   return 0;
 }

In this example, j is an unreferenced variable.


    This article is issued from Wikipedia - version of the 10/15/2015. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.