12

setvbuf didn't work in linux?

view full story
linux-howto

https://bbs.archlinux.org – Hi,all of you!I wrote some codes to test setvbuf function in linux.Here are the codes:#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <errno.h> char buf[10]; int main() { if((setvbuf(stdout,buf,_IOFBF,10)) != 0) { fprintf(stderr,"setvbuf() failed: %s\n",strerror(errno)); exit(1); } printf("123456789"); _exit(0); }As you can see,it should not output anything on screen.But,unfortunately,it outputs "123456789".I test the codes with archlinux,ubuntu,opensuse,and it's all the same.A (HowTos)