fork download
  1. #include <iostream>
  2. using namespace std;
  3. void func() {
  4. static int i=0; //static variable
  5. int j=0; //local variable
  6. i++;
  7. j++;
  8. cout<<"i=" << i<<" and j=" <<j<<endl;
  9. }
  10. int main()
  11. {
  12. func();
  13. func();
  14. func();
  15. }
Success #stdin #stdout 0s 5300KB
stdin
Standard input is empty
stdout
i=1 and j=1
i=2 and j=1
i=3 and j=1