fork download
  1. #include <stdio.h>
  2.  
  3. void sthng_fun(int i)
  4. {
  5. if (i) {
  6. static int counter = 0;
  7. counter++;
  8. printf("this function was called %d times with non-zero argument\n", counter);
  9. } else {
  10. printf("this function has been called %d times with non-zero argument\n", counter);
  11. }
  12.  
  13. }
  14.  
  15. int main(void)
  16. {
  17. sthng_fun(1);
  18. sthng_fun(1);
  19. sthng_fun(1);
  20.  
  21. return 0;
  22. }
  23.  
Compilation error #stdin compilation error #stdout 0s 2008KB
stdin
Standard input is empty
compilation info
prog.c: In function 'sthng_fun':
prog.c:10:77: error: 'counter' undeclared (first use in this function)
   printf("this function has been called %d times with non-zero argument\n", counter);
                                                                             ^
prog.c:10:77: note: each undeclared identifier is reported only once for each function it appears in
stdout
Standard output is empty