I am running this below 'C' program which has an infinite loop. I see the CPU reaching almost 99% using the 'top' command. Then suddenly the program stops. I was curious to know what rule in the system is causing it to stop.
I am running this under a docker image alpine:3.1 (+ some modules) and I just simply start its ash (alpine's bash).
Also, I can not find ulimit.
#include <stdio.h>
int main() {
int marks[10],i,n,sum=0;
printf("Enter number of students: ");
scanf("%d",&n);
for(i = 0; i < n; --i) {
//printf("Enter marks of student%d: ",i+1);
int c;
c = 5;
int a;
a = c;
}
return 0;
}
n
has a garbage value, since you did not check the result fromscanf
. That could be anything, causing an indefinite loop in the program.