setbuf.c

来自「C标准库源代码」· C语言 代码 · 共 55 行

C
55
字号
/***
*setbuf.c - give new file buffer
*
*       Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
*
*Purpose:
*       defines setbuf() - given a buffer to a stream or make it unbuffered
*
*******************************************************************************/

#include <cruntime.h>
#include <stdio.h>
#include <dbgint.h>

/***
*void setbuf(stream, buffer) - give a buffer to a stream
*
*Purpose:
*       Allow user to assign his/her own buffer to a stream.
*               if buffer is not NULL, it must be BUFSIZ in length.
*               if buffer is NULL, stream will be unbuffered.
*
*       Since setbuf()'s functionality is a subset of setvbuf(), simply
*       call the latter routine to do the actual work.
*
*       NOTE: For compatibility reasons, setbuf() uses BUFSIZ as the
*       buffer size rather than _INTERNAL_BUFSIZ. The reason for this,
*       and for the two BUFSIZ constants, is to allow stdio to use larger
*       buffers without breaking (already) compiled code.
*
*Entry:
*       FILE *stream - stream to be buffered or unbuffered
*       char *buffer - buffer of size BUFSIZ or NULL
*
*Exit:
*       None.
*
*Exceptions:
*
*******************************************************************************/

void __cdecl setbuf (
        FILE *stream,
        char *buffer
        )
{
        _ASSERTE(stream != NULL);

        if (buffer == NULL)
                setvbuf(stream, NULL, _IONBF, 0);
        else
                setvbuf(stream, buffer, _IOFBF, BUFSIZ);

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?