I want to turn off the buffering for the stdout for getting the exact result for the following code
while(1) {
printf(".");
sleep(1);
}
You can use the setvbuf function<\/a> :
setvbuf(stdout, NULL, _IONBF, 0);
You can also use setbuf
setbuf(stdout, NULL);
This will take care of everything
Use fflush(FILE *stream)
with stdout
as the parameter.
You can do this:
write(1, ".", 1);
Use fflush(stdout)<\/code> .
You can use it after every
printf<\/code> call to force the buffer to flush.
"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.