• <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 閱讀(772) 評論(0)  編輯 收藏 引用

            導航

            <2008年11月>
            2627282930311
            2345678
            9101112131415
            16171819202122
            23242526272829
            30123456

            統計

            常用鏈接

            留言簿(19)

            隨筆檔案

            文章檔案

            收藏夾

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            精品久久久久久中文字幕| 天天综合久久久网| 伊人久久大香线蕉亚洲五月天| 久久国产热精品波多野结衣AV| 国产精品欧美久久久久天天影视| 久久综合偷偷噜噜噜色| 久久精品国产精品亚洲精品| 久久精品国产一区二区电影| 久久综合给久久狠狠97色| 欧美午夜A∨大片久久 | 狠狠色丁香婷婷久久综合不卡| 色成年激情久久综合| 久久精品国产亚洲AV不卡| 热久久国产欧美一区二区精品| 久久午夜无码鲁丝片秋霞| 久久久无码精品亚洲日韩软件| 免费观看成人久久网免费观看| 一本久久免费视频| 美女久久久久久| 久久国产精品一区二区| 日韩精品久久久久久久电影蜜臀 | 72种姿势欧美久久久久大黄蕉 | 91久久精品电影| 久久国产精品无码网站| 国产∨亚洲V天堂无码久久久 | 久久久噜噜噜久久中文字幕色伊伊| 亚洲狠狠婷婷综合久久久久| 午夜人妻久久久久久久久| 日本久久中文字幕| 久久久久一级精品亚洲国产成人综合AV区| 久久久无码精品亚洲日韩蜜臀浪潮 | 青青草原综合久久| 97久久超碰国产精品2021| 亚洲日本va中文字幕久久| 久久国产精品无| 久久天天躁夜夜躁狠狠| 久久99热这里只有精品66| 久久精品aⅴ无码中文字字幕不卡| 日批日出水久久亚洲精品tv| 伊人久久大香线蕉精品不卡| 亚洲色欲久久久久综合网|