Initialise a variable to 0, and increment it on every iteration?
int num = 0;
while (something) {
num++;
...
}
printf("number of iterations: %d\n", num);
More Related Contents:
- How it works in C? (implement strcat function) [closed]
- how to change this code to be able to solve this challenge?
- How to break out of while loop in C
- Why is “while ( !feof (file) )” always wrong?
- How to write a while loop with the C preprocessor?
- For vs. while in C programming?
- Why is “while( !feof(file) )” always wrong?
- How to prevent system hang before watchdog timer task kicks in
- While-loop ignores scanf the second time
- When implementing an infinite loop, is there a difference in using while(1) vs for(;;) vs goto (in C)?
- Using getchar() in a while loop
- Why do i have to input EOF 3 times when using fgets?
- Behaviour of scanf when newline is in the format string
- How to read these mixture of data in C
- Why malloc+memset is slower than calloc?
- makefile:4: *** missing separator. Stop
- Is it better to use C void arguments “void foo(void)” or not “void foo()”? [duplicate]
- Macro definition to determine big endian or little endian machine?
- Why does glibc’s strlen need to be so complicated to run quickly?
- Standard alternative to GCC’s ##__VA_ARGS__ trick?
- Mapping a numeric range onto another
- How to get function’s name from function’s pointer in Linux kernel?
- How to call C from Swift?
- Is it possible to determine the thread holding a mutex?
- Are empty macro definitions allowed in C? How do they behave?
- Reading a text file backwards in C
- Passing too many arguments to printf
- Is the sizeof(enum) == sizeof(int), always?
- What primitive data type is time_t? [duplicate]
- C: How to wrap a float to the interval [-pi, pi)