ChinaUnix.net
相关文章推荐:

c语言中fflush详细用法

有时见到有使用setbuf() 与 fflush(stdin) fflush(stdout) 这些函数,却不知它门有什么实际的作用,有时在程序中将他们去掉一样也可以运行。那用他们有何作用呢? :?:

by yangfan - C/C++ - 2003-05-13 18:23:31 阅读(3746) 回复(3)

相关讨论

请问我想用fflush函数把标准输入stdin,输入到文件text中该怎么做?

by bj1234567890 - C/C++ - 2009-08-25 16:19:16 阅读(1316) 回复(3)

求教 #define fflush(handle) 这句代码如何理解?谢谢

by jxymax - C/C++ - 2009-06-14 22:54:33 阅读(1760) 回复(6)

同样一个程序: #include int main() { char s[64]; int i; scanf("%d",&i); fflush(stdin); gets(s); puts(s); return 0; } 输入: 1 string 在windows上,缓冲区被清空了,gets()什么也没得到。 但是在linux上面,空格+string却给了gets()。 为什么?

by prot - C/C++ - 2008-08-21 14:13:55 阅读(1445) 回复(3)

想实验下printf的缓冲,于是写了下面一小段代码 #include #include #include #include int main (int argc, char* argv[]) {     int pipe_fd[2];     if (-1 == pipe(pipe_fd))     {         printf("make pipe error!\n");        &nbs...

by 0oo0 - C/C++ - 2008-02-19 22:20:16 阅读(1840) 回复(5)

为测试输入缓冲清空,代码test.c如下: #include int main(void) { char c1,c2; top: printf("Input number->"); scanf("%c",&c1); fflush(stdin); printf("c1 is %c\n",c1); goto top; return 0; } #gcc -o test test.c #./test #Input number->3 c is 3 Input number->c1 is Input number-> 可见fflush(stdin)没起作用,敢问是什么问题?

by cuinantrue - C/C++ - 2006-03-30 16:19:56 阅读(2792) 回复(3)

请问:在SCO OpenServer 5.05下,使用fflush函数经常会出现这样的情况,程序没有任何提示就退了出去,也不会产生core,不知道这是怎么回事?急

by nmzqzw - 其他UNIX - 2005-01-11 14:28:33 阅读(902) 回复(1)

请问 fflush(stdout); 有什么用,具体是干什么的。

by 不倒翁(A) - C/C++ - 2004-06-30 18:18:14 阅读(1967) 回复(7)

Remarks The fflush function flushes a stream. If the file associated with stream is open for output, fflush writes to that file the contents of the buffer associated with the stream. If the stream is open for input, fflush clears the contents of the buffer. fflush negates the effect of any prior call to ungetc against stream. Also, fflush(NULL) flushes all streams opened for output. The stream re...

by kingld - C/C++ - 2003-12-11 14:40:23 阅读(2135) 回复(6)

As we known that fflush(3) is a standard C library function. So it should be has the same behavior on any platforms which support standard ansi C library. But when I wrote fflush(stdin); Windows will discard all things stored in the system's standard input buffer. So when I issue getchar(3) next fflush(3), I could get correct character I wish. FreeBSD, contrasted with windows, has not the effe...

by gvim - C/C++ - 2005-05-14 11:39:08 阅读(882) 回复(2)

redhat AS3下,用ffush(stdin)好像不起作用艾。同样的程序放到windows平台下用vc+proC运行完全没有问题;但在redhat+PROC下(编译也没有问题)运行时输入缓冲区老有问题,好像fflush(stdin)不起作用一样。请教大家unix下如何清除缓冲区! 以下代码在linux上运行输入字母时出现死循环,在windows下就不会出现。 #include "stdio.h" main() { int action; for(;;) { printf("\n 1 :Query,"); printf(" 2 :Insert,"); printf(" ...

by dongzi1980 - C/C++ - 2007-10-25 01:28:56 阅读(3637) 回复(13)