Why this program print nothing.anyone who can explain reasion behind this
#include <stdio.h>
int main(){
int i = 0;
for(;;){
if(i==10)
continue;
printf("%d ",++i);
}
return(0);
}
Why this program print nothing.anyone who can explain reasion behind this
#include <stdio.h>
int main(){
int i = 0;
for(;;){
if(i==10)
continue;
printf("%d ",++i);
}
return(0);
}
The reason is that printf
does not immediately print to the screen. Instead, it caches the input in internal buffer, and when either a newline "\n" character or an explicit flush call arrives - it will print it all at once.
Now in your case, I reaches value of 10 and the program is stuck. Flush or newline never arrive. Try this and see the difference:
printf("%d ",++i);
fflush(stdout);