• <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)  編輯 收藏 引用

            導航

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

            統計

            常用鏈接

            留言簿(19)

            隨筆檔案

            文章檔案

            收藏夾

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            久久久久久久尹人综合网亚洲| 欧美粉嫩小泬久久久久久久| 久久亚洲春色中文字幕久久久| 狠狠色丁香婷婷久久综合不卡 | 亚洲狠狠婷婷综合久久蜜芽| 浪潮AV色综合久久天堂| 久久国产视频网| 久久精品国产91久久综合麻豆自制| 亚洲欧美另类日本久久国产真实乱对白| 中文字幕日本人妻久久久免费| 色成年激情久久综合| 亚洲国产精品成人久久| 免费一级欧美大片久久网| 免费国产99久久久香蕉| 日韩精品久久久肉伦网站| 国产精品久久婷婷六月丁香| 久久国产视屏| 国产ww久久久久久久久久| 97久久国产亚洲精品超碰热| 无遮挡粉嫩小泬久久久久久久| 欧美久久天天综合香蕉伊| 国产精品免费久久久久久久久| 国产精品久久精品| 精品久久久久久无码专区 | 青青草国产精品久久| 久久无码人妻一区二区三区 | 激情五月综合综合久久69| 日本久久久精品中文字幕| 久久综合九色综合欧美狠狠| 99久久99这里只有免费的精品| 综合久久国产九一剧情麻豆| 久久精品国产男包| 男女久久久国产一区二区三区| 性做久久久久久久| 久久婷婷成人综合色综合| 国产精品99久久99久久久| 亚洲女久久久噜噜噜熟女| 久久人爽人人爽人人片AV| 国产精品久久永久免费| 999久久久免费国产精品播放| 久久久久久毛片免费看|