使用 Microsoft 登录
登录或创建帐户。
你好,
使用其他帐户。
你有多个帐户
选择要登录的帐户。

症状

当您运行的应用程序调用_sntscanf_s函数时,则调用应返回EOF(-1)值。但是,当您运行 Windows 10 企业 2015 LTSB 应用程序,请插入的 null 字符将被忽略。这会导致接收错误的值为1 ,而不使用EOF (-1)值的numFields字段。

例如,下面的 Visual C++ 应用程序中发生此问题:

#include "stdafx.h"
#include "string.h"
#include "stdlib.h"

int main()
{
    TCHAR szBuff[256];
    double temp = 0;
    wcscpy_s(szBuff, L"77777777");

    // this should force the _sntscanf_s to return an EOF (-1) value
    szBuff[0] = '\0';

    int numFields = _sntscanf_s(szBuff, _countof(szBuff), _T("%lf"), &temp);
    if (numFields == EOF)
    {
        printf("Correct Behavior!!!\r\n");
    }
    else
    {
        printf("BUG: _sntscanf_s failed to return EOF!!!\r\n");
    }
    return 0;
}

原因

在 Ucrtbase.dll 文件中包含在 Windows 10 企业 2015 LTSB common_vsscanf函数中的已知问题会出现此问题。此问题会影响整个scanf系列的功能:

  • _vsscanf_l

  • vsscanf

  • _sscanf_l

  • sscanf

  • _vsscanf_s_l

  • vsscanf_s

  • _sscanfs_l

  • sscanf_s

  • _snscanf_l

  • _snscanf_s

  • _snscanf_s_l

  • _snscanf_s

  • _vswscanf_l

  • vswscanf

  • _swscanf_l

  • swscanf

  • _vswscanf_s_l

  • vswscanf_s

  • _wsscanfs_l

  • swscanf_s

  • _snwscanf_l

  • _snwscanf_s

  • _snwscanf_s_l

  • _snwscanf_s

解决方案

若要解决此问题,请安装维修更新2018,5 月 8--KB4103716 (操作系统生成 10240.17861)

参考资料

好的 C 运行库 (CRT) 重构

引入了通用的 CRT

需要更多帮助?

需要更多选项?

了解订阅权益、浏览培训课程、了解如何保护设备等。

社区可帮助你提出和回答问题、提供反馈,并听取经验丰富专家的意见。

此信息是否有帮助?

你对语言质量的满意程度如何?
哪些因素影响了你的体验?
按“提交”即表示你的反馈将用于改进 Microsoft 产品和服务。 你的 IT 管理员将能够收集此数据。 隐私声明。

谢谢您的反馈!

×