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

            導航

            <2009年5月>
            262728293012
            3456789
            10111213141516
            17181920212223
            24252627282930
            31123456

            統計

            常用鏈接

            留言簿(19)

            隨筆檔案

            文章檔案

            收藏夾

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            久久久久国产视频电影| 亚洲国产天堂久久综合| 久久WWW免费人成一看片| 香港aa三级久久三级老师2021国产三级精品三级在 | 久久99久久无码毛片一区二区| 99久久99久久精品国产| 久久久久亚洲精品无码网址| 三级片免费观看久久| 免费久久人人爽人人爽av| 久久综合给合久久狠狠狠97色69 | 久久青青国产| 精品久久人人爽天天玩人人妻| 国产精品久久久久久久久免费| 久久久久亚洲AV综合波多野结衣 | 亚洲国产视频久久| 久久国产成人精品麻豆| 99久久香蕉国产线看观香| 久久免费视频网站| 久久久国产打桩机| 久久亚洲国产精品123区| 精品永久久福利一区二区| 午夜视频久久久久一区| 久久精品国产亚洲网站| 日韩久久久久久中文人妻| 一本色道久久88综合日韩精品| 狠狠色婷婷综合天天久久丁香 | 伊人久久大香线蕉AV一区二区| 国产Av激情久久无码天堂 | 一本一道久久综合狠狠老| 日本精品久久久久影院日本| 久久综合狠狠色综合伊人| 久久精品国产久精国产思思| 99久久综合国产精品免费| 欧美激情精品久久久久久| 久久国产精品免费一区二区三区| 久久国产精品成人片免费| 亚洲中文字幕无码久久综合网| 一本久久a久久精品综合香蕉 | 99久久精品国产麻豆| 99久久777色| 精品久久久久久国产91|