我想问下 fflush(studio);括号里面应该是什么!
今天我们老师说他的功能主要是清除gets带来的空格什么的
上课太着急了写的有点草现在看不懂了,谢谢哪里能告诉我!
參考答案:看你括号里面的意思,我觉得应该是使用这个函数,是需要stdio.h这个头文件的;
但是fflush这个函数,需要的参数是一个结构体的指针;
fflush <stdio.h>
int fflush( FILE *stream );
Parameters
stream
Pointer to FILE structure
Libraries
All versions of the C run-time libraries.
Return Values
fflush returns 0 if the buffer was successfully flushed. The value 0 is also returned in cases in which the specified stream has no buffer or is open for reading only. A return value of EOF indicates an error.
Note If fflush returns EOF, data may have been lost due to a write failure. When setting up a critical error handler, it is safest to turn buffering off with the setvbuf function.
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 remains open after the call. fflush has no effect on an unbuffered stream.
Buffers are normally maintained by the operating system, which determines the optimal time to write the data automatically to disk: when a buffer is full, when a stream is closed, or when a program terminates normally without closing the stream.