• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            char *fgets( char *string, int n, FILE *stream )的返回值是首地址

            如果n <= 0,返回NULL
            如果n == 1,返回"",也就是一個空串。
            如果成功返回值等于string,也就是獲得的字符串的首地址。
            如果出錯,或者讀到FILE的結尾,返回NULL.

            以下是這個函數的實現:

            /***
            *fgets.c - get string from a file
            *
            * Copyright (c) Microsoft Corporation. All rights reserved.
            *
            *Purpose:
            * defines fgets() - read a string from a file
            *
            *******************************************************************************/

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

            /***
            *char *fgets(string, count, stream) - input string from a stream
            *
            *Purpose:
            * get a string, up to count-1 chars or '\n', whichever comes first,
            * append '\0' and put the whole thing into string. the '\n' IS included
            * in the string. if count<=1 no input is requested. if EOF is found
            * immediately, return NULL. if EOF found after chars read, let EOF
            * finish the string as '\n' would.
            *
            *Entry:
            * char *string - pointer to place to store string
            * int count - max characters to place at string (include \0)
            * FILE *stream - stream to read from
            *
            *Exit:
            * returns string with text read from file in it.
            * if count <= 0 return NULL
            * if count == 1 put null string in string
            * returns NULL if error or end-of-file found immediately
            *
            *Exceptions:
            *
            *******************************************************************************/

            _TSCHAR * __cdecl _fgetts (
            _TSCHAR *string,
            int count,
            FILE *str
            )
            {
            REG1 FILE *stream;
            REG2 _TSCHAR *pointer = string;
            _TSCHAR *retval = string;
            int ch;

            _VALIDATE_RETURN(( string != NULL ) || ( count == 0 ), EINVAL, NULL);
            _VALIDATE_RETURN(( count >= 0 ), EINVAL, NULL);
            _VALIDATE_RETURN(( str != NULL ), EINVAL, NULL);

            if (count == 0)
            {
            return NULL;
            }

            /* The C Standard states the input buffer should remain
            unchanged if EOF is encountered immediately. Hence we
            do not blank out the input buffer here */

            /* Init stream pointer */
            stream = str;

            _lock_str(stream);
            __try {

            #ifndef _UNICODE
            _VALIDATE_STREAM_ANSI_SETRET(stream, EINVAL, retval, NULL);
            #endif /* _UNICODE */
            if(retval!=NULL)
            {
            while (--count)
            {
            if ((ch = _fgettc_nolock(stream)) == _TEOF)
            {
            if (pointer == string) {
            retval=NULL;
            goto done;
            }

            break;
            }

            if ((*pointer++ = (_TSCHAR)ch) == _T('\n'))
            break;
            }
            *pointer = _T('\0');
            }


            /* Common return */
            done:

            ; }
            __finally {
            _unlock_str(stream);
            }

            return(retval);
            }

            posted on 2009-05-20 09:22 wrh 閱讀(770) 評論(0)  編輯 收藏 引用

            導航

            <2010年12月>
            2829301234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            統計

            常用鏈接

            留言簿(19)

            隨筆檔案

            文章檔案

            收藏夾

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            狠狠色丁香婷婷久久综合不卡 | 99精品久久精品一区二区| 国内精品久久久久影院亚洲| 亚洲AV日韩AV永久无码久久| 亚洲午夜久久久精品影院| 久久久久久精品成人免费图片| 久久w5ww成w人免费| 久久www免费人成看国产片| 久久久久久精品免费看SSS| 国产亚洲婷婷香蕉久久精品| 一个色综合久久| 亚洲狠狠综合久久| 久久99国产综合精品免费| 久久有码中文字幕| 精品久久久久久国产潘金莲| 久久中文字幕人妻熟av女| 久久久网中文字幕| 国产精品欧美久久久久天天影视| 久久精品国产AV一区二区三区 | 久久笫一福利免费导航 | 俺来也俺去啦久久综合网| 亚洲七七久久精品中文国产| 青青草原综合久久| 人妻少妇久久中文字幕一区二区| 97香蕉久久夜色精品国产| 婷婷久久综合| 欧美一区二区久久精品| 中文国产成人精品久久亚洲精品AⅤ无码精品 | 亚洲国产成人久久综合一| 国产精品99久久久久久人| 99精品国产99久久久久久97| 久久久久亚洲AV成人网人人网站| 久久亚洲精品无码播放| 日韩久久久久中文字幕人妻| 免费精品久久久久久中文字幕| 久久精品国产亚洲Aⅴ蜜臀色欲| 国产免费久久精品99久久| 88久久精品无码一区二区毛片 | 99热成人精品免费久久| 久久香蕉一级毛片| 国产午夜精品久久久久九九|