#include <stdio.h>
int setvbuf(FILE *stream, char *buf, int mode, size_t size);
#include <stdio.h>
#include <stdlib.h>
#define BUF_SIZE 1024
static char buf[BUF_SIZE];
int main(void)
{
if (setvbuf(stdout, buf, _IOFBF, BUF_SIZE) != 0) {
perror("setvbuf");
exit(EXIT_FAILURE);
}
printf ("hello world\n");
sleep(2);
printf ("hello linux\n");
sleep(2);
fflush(stdout);
return 0;
}
beyes@beyes :~/c/setvbuf> ./setvbuf
hello world
hello linux
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |