Read documentation of scanf(3) and of fflush(3)
Always test the result of scanf
printf("Enter Number Of Processes");
fflush(NULL);
if (scanf("%d",&n)<1)
{ perror("scanf nb process"); exit(EXIT_FAILURE); ; }
(do likewise for your other calls to scanf
...)
and at least call fflush
at end of each for
loop, e.g.
for(i=0;i<n;i++){
printf("%c",p[i].name);
printf("%d",p[i].arv);
printf("%d",p[i].burst);
fflush(NULL);
}
since stdio(3) is buffered. BTW, you'll be surprised by the output. You generally should end each (or at least most) printf
format string with
BTW, you should compile with all warnings & debug info (gcc -Wall -Wextra -g
) and you should use the debugger (gdb
)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…