Skip to content

Latest commit

 

History

History
27 lines (19 loc) · 593 Bytes

Notes.md

File metadata and controls

27 lines (19 loc) · 593 Bytes

static

In C the static keyword is used in 2 cases:

  • For variables:

    int fun() {
      static int count = 0;
      count++;
      return count;
    }

    Even if function has been executed, the value of a is kept in memory. So, in this example, every time we call this function a is incremented by 1.

  • For functions:

    static int function() {
      // ...
    }

    This function is visible only by functions in the same file (translation unit).

Return to the index