⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 closeall.c

📁 C语言库函数的原型,有用的拿去
💻 C
字号:
/***
*closeall.c - close all open files
*
*       Copyright (c) Microsoft Corporation. All rights reserved.
*
*Purpose:
*       defines _fcloseall() - closes all open files except stdin, stdout
*       stdprn, stderr, and stdaux.
*
*******************************************************************************/

#include <cruntime.h>
#include <windows.h>
#include <stdio.h>
#include <file2.h>
#include <internal.h>
#include <malloc.h>
#include <mtdll.h>
#include <dbgint.h>


/***
*int _fcloseall() - close all open streams
*
*Purpose:
*       Closes all streams currently open except for stdin/out/err/aux/prn.
*       tmpfile() files are among those closed.
*
*Entry:
*       None.
*
*Exit:
*       returns number of streams closed if OK
*       returns EOF if fails.
*
*Exceptions:
*
*******************************************************************************/

int __cdecl _fcloseall (
        void
        )
{
        REG2 int count = 0;
        REG1 i;

        _mlock(_IOB_SCAN_LOCK);
        __try {
            for ( i = 3 ; i < _nstream ; i++ ) {
                if ( __piob[i] != NULL ) {
                    /*
                     * if the stream is in use, close it
                     */
                    if ( inuse( (FILE *)__piob[i] ) && (fclose( __piob[i] ) !=
                             EOF) )
                        count++;

                    /*
                     * if stream is part of a _FILEX we allocated, free it.
                     */
                    if ( i >= _IOB_ENTRIES ) {
                        DeleteCriticalSection( &(((_FILEX *)__piob[i])->lock) );
                        _free_crt( __piob[i] );
                        __piob[i] = NULL;
                    }
                }
            }
        }
        __finally {
            _munlock(_IOB_SCAN_LOCK);
        }

        return(count);
}

⌨️ 快捷键说明

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