Files
linux-kernel-module-cheat/userland/c/infinite_loop.c
Ciro Santilli 六四事件 法轮功 9fba97740c file_write_read.c: move from cpp-cheat
Improve README C section with example tree.
2019-06-07 00:00:03 +00:00

32 lines
592 B
C

/* https://github.com/cirosantilli/linux-kernel-module-cheat#c
*
* Loop infinitely. Print an integer whenever a period is reached:
*
* ....
* ./infinite_loop [period]
* ....
*/
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
uintmax_t i, j, period;
if (argc > 1) {
period = strtoumax(argv[1], NULL, 10);
} else {
period = 100000000;
}
i = 0;
j = 0;
while (1) {
i++;
if (i % period == 0) {
printf("%ju\n", j);
j++;
}
}
}