How to count the number of times we run a function in C

1 Answer

0 votes
#include <stdio.h>
 
int count_activation(void);
 
int main(void)
{
    count_activation();
    count_activation();
    printf("%d", count_activation());
    
    return 0;
}
int count_activation(void) 
{ 
    static int n = 0;
    
    n++;
    
    return n;
} 

  
/*
run:
 
3

*/

 



answered Nov 24, 2015 by avibootz

Related questions

1 answer 139 views
1 answer 241 views
2 answers 206 views
206 views asked Feb 27, 2019 by avibootz
1 answer 264 views
...