CRT 函数的安全增强版本Security-Enhanced Versions of CRT Functions

可提供更安全版本的运行时库例程。More secure versions of run-time library routines are available. 有关 CRT 中的安全改进的详细信息,请参阅 CRT 中的安全功能For further information concerning Security Enhancements in the CRT, see Security Features in the CRT.

安全函数Secure Functions

CRT 函数CRT Function 安全性增强的函数Security enhanced function 使用Use
_access、_waccess_access, _waccess _access_s、_waccess_s_access_s, _waccess_s 确定文件访问权限Determine file-access permission
_alloca_alloca _malloca_malloca 在堆栈上分配内存Allocate memory on the stack
asctime、_wasctimeasctime, _wasctime asctime_s、_wasctime_sasctime_s, _wasctime_s struct tm 类型到字符串的转换时间Convert time from type struct tm to character string
bsearchbsearch bsearch_sbsearch_s 执行排序数组的二进制搜索Perform a binary search of a sorted array
已过时的函数Obsolete function _cgets_s、_cgetws_s_cgets_s, _cgetws_s 从控制台获取一个字符串Get a character string from the console
_chsize_chsize _chsize_s_chsize_s 更改文件的大小Change the size of a file
clearerrclearerr clearerr_sclearerr_s 重置流的错误指示器Reset the error indicator for a stream
_control87、_controlfp、__control87_2_control87, _controlfp, __control87_2 _controlfp_s_controlfp_s 获取和设置浮点控制字Get and set the floating-point control word
_cprintf、_cprintf_l、_cwprintf、_cwprintf_l_cprintf, _cprintf_l, _cwprintf, _cwprintf_l _cprintf_s、_cprintf_s_l、_cwprintf_s、_cwprintf_s_l_cprintf_s, _cprintf_s_l, _cwprintf_s, _cwprintf_s_l 格式化并打印到控制台Format and print to the console
_cscanf、_cscanf_l、_cwscanf、_cwscanf_l_cscanf, _cscanf_l, _cwscanf, _cwscanf_l _cscanf_s、_cscanf_s_l、_cwscanf_s、_cwscanf_s_l_cscanf_s, _cscanf_s_l, _cwscanf_s, _cwscanf_s_l 从控制台读取格式化的数据Read formatted data from the console
ctime、_ctime32、_ctime64、_wctime、_wctime32、_wctime64ctime, _ctime32, _ctime64, _wctime, _wctime32, _wctime64 _ctime_s、_ctime32_s、_ctime64_s、_wctime_s、_wctime32_s、_wctime64_s_ctime_s, _ctime32_s, _ctime64_s, _wctime_s, _wctime32_s, _wctime64_s time_t__time32_t__time64_t 类型到字符串的转换时间Convert time from type time_t, __time32_t or __time64_t to character string
_ecvt_ecvt _ecvt_s_ecvt_s double 数字转换为字符串Convert a double number to a string
_fcvt_fcvt _fcvt_s_fcvt_s 将浮点数转换为字符串Converts a floating-point number to a string
fopen、_wfopen_wfopenfopen, _wfopen fopen_s、_wfopen_sfopen_s, _wfopen_s 打开文件Open a file
fprintf、_fprintf_l、fwprintf、_fwprintf_lfprintf, _fprintf_l, fwprintf, _fwprintf_l fprintf_s、_fprintf_s_l、fwprintf_s、_fwprintf_s_lfprintf_s, _fprintf_s_l, fwprintf_s, _fwprintf_s_l 将格式化数据输出到流Print formatted data to a stream
freadfread fread_sfread_s 从文件中读取Read from a file
_fread_nolock_fread_nolock _fread_nolock_s_fread_nolock_s 从文件中读取,同时无需使用多线程写入锁定Read from a file without using a multi-thread write lock
freopen、_wfreopenfreopen, _wfreopen freopen_s、_wfreopen_sfreopen_s, _wfreopen_s 重新打开文件Reopen the file
fscanf、_fscanf_l、fwscanf、_fwscanf_lfscanf, _fscanf_l, fwscanf, _fwscanf_l fscanf_s、_fscanf_s_l、fwscanf_s、_fwscanf_s_lfscanf_s, _fscanf_s_l, fwscanf_s, _fwscanf_s_l 从流中读取带格式的数据Read formatted data from a stream
_ftime, _ftime32, _ftime64_ftime, _ftime32, _ftime64 _ftime_s、_ftime32_s、_ftime64_s_ftime_s, _ftime32_s, _ftime64_s 获取当前时间Get the current time
_gcvt_gcvt _gcvt_s_gcvt_s 将浮点值转换为字符串,并将其存储在缓冲区中Convert a floating-point value to a string, and store it in a buffer
getenv、_wgetenvgetenv, _wgetenv getenv_s、_wgetenv_sgetenv_s, _wgetenv_s 从当前环境中获取值。Get a value from the current environment.
已过时的函数Obsolete function gets_s、_getws_sgets_s, _getws_s stdin 流中获取行Get a line from the stdin stream
gmtime、_gmtime32、_gmtime64gmtime, _gmtime32, _gmtime64 _gmtime32_s、_gmtime64_s_gmtime32_s, _gmtime64_s 将时间从类型 time_t 转换为 struct tm 或从类型 __time64_t 转换为 struct tmConvert time from type time_t to struct tm or from type __time64_t to struct tm
_itoa、_i64toa、_ui64toa、_itow、_i64tow、_ui64tow_itoa, _i64toa, _ui64toa, _itow, _i64tow, _ui64tow _itoa_s、_i64toa_s、_ui64toa_s、_itow_s、_i64tow_s、_ui64tow_s_itoa_s, _i64toa_s, _ui64toa_s, _itow_s, _i64tow_s, _ui64tow_s 将整数转换为字符串Convert an integer to a string
_lfind_lfind _lfind_s_lfind_s 执行指定键的线性搜索Perform a linear search for the specified key
localtime、_localtime32、_localtime64localtime, _localtime32, _localtime64 localtime_s、_localtime32_s、_localtime64_slocaltime_s, _localtime32_s, _localtime64_s 使用本地更正将时间从类型 time_t 转换为 struct tm 或从类型 __time64_t 转换为 struct tmConvert time from type time_t to struct tm or from type __time64_t to struct tm with local correction
_lsearch_lsearch _lsearch_s_lsearch_s 执行值的线性搜索;如果未找到,则添加到列表的末尾Perform a linear search for a value; adds to end of list if not found
_ltoa、_ltow_ltoa, _ltow _ltoa_s、_ltow_s_ltoa_s, _ltow_s 将长整数转换为字符串Convert a long integer to a string
_makepath、_wmakepath_makepath, _wmakepath _makepath_s、_wmakepath_s_makepath_s, _wmakepath_s 从组件创建路径名Create a path name from components
_mbccpy、_mbccpy_l_mbccpy, _mbccpy_l _mbccpy_s、_mbccpy_s_l_mbccpy_s, _mbccpy_s_l 将多字节字符从一个字符串复制到另一个字符串Copy a multibyte character from one string to another string
_mbsnbcat、_mbsnbcat_l_mbsnbcat, _mbsnbcat_l _mbsnbcat_s、_mbsnbcat_s_l_mbsnbcat_s, _mbsnbcat_s_l 最多将一个多字节字符字符串的第一个 n 字节追加到另一个字符串Append, at most, the first n bytes of one multibyte character string to another
_mbsnbcpy、_mbsnbcpy_l_mbsnbcpy, _mbsnbcpy_l _mbsnbcpy_s、_mbsnbcpy_s_l_mbsnbcpy_s, _mbsnbcpy_s_l 将字符串的 n 字节复制到目标字符串Copy n bytes of a string to a destination string
_mbsnbset、_mbsnbset_l_mbsnbset, _mbsnbset_l _mbsnbset_s、_mbsnbset_s_l_mbsnbset_s, _mbsnbset_s_l 将字符串的第一个 n 字节设置为指定字符Set the first n bytes of a string to a specified character
mbsrtowcsmbsrtowcs mbsrtowcs_smbsrtowcs_s 将多字节字符字符串转换为对应的宽字符字符串Convert a multibyte character string to a corresponding wide character string
mbstowcs、_mbstowcs_lmbstowcs, _mbstowcs_l mbstowcs_s、_mbstowcs_s_lmbstowcs_s, _mbstowcs_s_l 将多字节字符序列转换为对应的宽字符序列Convert a sequence of multibyte characters to a corresponding sequence of wide characters
memcpy、wmemcpymemcpy, wmemcpy memcpy_s、wmemcpy_smemcpy_s, wmemcpy_s 在缓冲区之间进行字符复制操作Copy characters between buffers
memmove、wmemmovememmove, wmemmove memmove_s、wmemmove_smemmove_s, wmemmove_s 从一个缓冲区移动到另一个缓冲区Move one buffer to another
_mktemp、_wmktemp_mktemp, _wmktemp _mktemp_s、_wmktemp_s_mktemp_s, _wmktemp_s 创建唯一文件名Create a unique filename
printf、_printf_l、wprintf、_wprintf_lprintf, _printf_l, wprintf, _wprintf_l printf_s、_printf_s_l、wprintf_s、_wprintf_s_lprintf_s, _printf_s_l, wprintf_s, _wprintf_s_l 将格式化输出打印至标准输出流Print formatted output to the standard output stream
_putenv、_wputenv_putenv, _wputenv _putenv_s、_wputenv_s_putenv_s, _wputenv_s 创建,修改或移除环境变量Create, modify, or remove environment variables
qsortqsort qsort_sqsort_s 执行快速排序Perform a quick sort
randrand rand_srand_s 生成伪随机数Generate a pseudorandom number
scanf、_scanf_l、wscanf、_wscanf_lscanf, _scanf_l, wscanf, _wscanf_l scanf_s、_scanf_s_l、wscanf_s、_wscanf_s_lscanf_s, _scanf_s_l, wscanf_s, _wscanf_s_l 从标准输入流中读取格式化数据Read formatted data from the standard input stream
_searchenv、_wsearchenv_searchenv, _wsearchenv _searchenv_s、_wsearchenv_s_searchenv_s, _wsearchenv_s 使用环境路径搜索文件Search for a file using environment paths
snprintf、_snprintf、_snprintf_l、_snwprintf、_snwprintf_lsnprintf, _snprintf, _snprintf_l, _snwprintf, _snwprintf_l _snprintf_s、_snprintf_s_l、_snwprintf_s、_snwprintf_s_l_snprintf_s, _snprintf_s_l, _snwprintf_s, _snwprintf_s_l 将设置格式的数据写入字符串Write formatted data to a string
_snscanf、_snscanf_l、_snwscanf、_snwscanf_l_snscanf, _snscanf_l, _snwscanf, _snwscanf_l _snscanf_s、_snscanf_s_l、_snwscanf_s、_snwscanf_s_l_snscanf_s, _snscanf_s_l, _snwscanf_s, _snwscanf_s_l 从字符串中读取指定长度的格式化数据。Read formatted data of a specified length from a string.
_sopen、_wsopen_sopen, _wsopen _sopen_s、_wsopen_s_sopen_s, _wsopen_s 打开文件以供共享Open a file for sharing
_splitpath、_wsplitpath_splitpath, _wsplitpath _splitpath_s、_wsplitpath_s_splitpath_s, _wsplitpath_s 将路径名称分解成组件Break a path name into components
sprintf、_sprintf_l、swprintf、_swprintf_l、__swprintf_lsprintf, _sprintf_l, swprintf, _swprintf_l, __swprintf_l sprintf_s、_sprintf_s_l、swprintf_s、_swprintf_s_lsprintf_s, _sprintf_s_l, swprintf_s, _swprintf_s_l 将设置格式的数据写入字符串Write formatted data to a string
sscanf、_sscanf_l、swscanf、_swscanf_lsscanf, _sscanf_l, swscanf, _swscanf_l sscanf_s、_sscanf_s_l、swscanf_s、_swscanf_s_lsscanf_s, _sscanf_s_l, swscanf_s, _swscanf_s_l 从字符串中读取格式化数据Read formatted data from a string
strcat、wcscat、_mbscatstrcat, wcscat, _mbscat strcat_s、wcscat_s、_mbscat_sstrcat_s, wcscat_s, _mbscat_s 追加字符串Append a string
strcpy、wcscpy、_mbscpystrcpy, wcscpy, _mbscpy strcpy_s、wcscpy_s、_mbscpy_sstrcpy_s, wcscpy_s, _mbscpy_s 复制字符串Copy a string
_strdate、_wstrdate_strdate, _wstrdate _strdate_s、_wstrdate_s_strdate_s, _wstrdate_s 以字符串形式返回当前系统日期Return current system date as string
strerror、_strerror、_wcserror、__wcserrorstrerror, _strerror, _wcserror, __wcserror strerror_s、_strerror_s、_wcserror_s、__wcserror_sstrerror_s, _strerror_s, _wcserror_s, __wcserror_s 获取系统错误信息(strerror_wcserror)或打印用户提供的错误消息(_strerror__wcserrorGet a system error message (strerror, _wcserror) or print a user-supplied error message (_strerror, __wcserror)
_strlwr、_wcslwr、_mbslwr、_strlwr_l、_wcslwr_l、_mbslwr_l_strlwr, _wcslwr, _mbslwr, _strlwr_l, _wcslwr_l, _mbslwr_l _strlwr_s、_strlwr_s_l、_mbslwr_s、_mbslwr_s_l、_wcslwr_s、_wcslwr_s_l_strlwr_s, _strlwr_s_l, _mbslwr_s, _mbslwr_s_l, _wcslwr_s, _wcslwr_s_l 将字符串转换为小写字母Convert a string to lowercase
strncat、_strncat_l、wcsncat、_wcsncat_l、_mbsncat、_mbsncat_lstrncat, _strncat_l, wcsncat, _wcsncat_l, _mbsncat, _mbsncat_l strncat_s、_strncat_s_l、wcsncat_s、_wcsncat_s_l、_mbsncat_s、_mbsncat_s_lstrncat_s, _strncat_s_l, wcsncat_s, _wcsncat_s_l, _mbsncat_s, _mbsncat_s_l 向字符串追加字符Append characters to a string
strncpy、_strncpy_l、wcsncpy、_wcsncpy_l、_mbsncpy、_mbsncpy_lstrncpy, _strncpy_l, wcsncpy, _wcsncpy_l, _mbsncpy, _mbsncpy_l strncpy_s、_strncpy_s_l、wcsncpy_s、_wcsncpy_s_l、_mbsncpy_s、_mbsncpy_s_lstrncpy_s, _strncpy_s_l, wcsncpy_s, _wcsncpy_s_l, _mbsncpy_s, _mbsncpy_s_l 将一个字符串的字符复制到另一个字符串Copy characters of one string to another
_strnset、_strnset_l、_wcsnset、_wcsnset_l、_mbsnset、_mbsnset_l_strnset, _strnset_l, _wcsnset, _wcsnset_l, _mbsnset, _mbsnset_l _strnset_s、_strnset_s_l、_wcsnset_s、_wcsnset_s_l、_mbsnset_s、_mbsnset_s_l_strnset_s, _strnset_s_l, _wcsnset_s, _wcsnset_s_l, _mbsnset_s, _mbsnset_s_l 将字符串的第一个 n 字符设置为指定字符Set the first n characters of a string to the specified character
_strset、_strset_l、_wcsset、_wcsset_l、_mbsset、_mbsset_l_strset, _strset_l, _wcsset, _wcsset_l, _mbsset, _mbsset_l _strset_s、_strset_s_l、_wcsset_s、_wcsset_s_l、_mbsset_s、_mbsset_s_l_strset_s, _strset_s_l, _wcsset_s, _wcsset_s_l, _mbsset_s, _mbsset_s_l 将字符串的所有字符都设置为指定字符Set all the characters of a string to the specified character
_strtime、_wstrtime_strtime, _wstrtime _strtime_s、_wstrtime_s_strtime_s, _wstrtime_s 以字符串形式返回当前系统时间Return current system time as string
strtok、_strtok_l、wcstok、_wcstok_l、_mbstok、_mbstok_lstrtok, _strtok_l, wcstok, _wcstok_l, _mbstok, _mbstok_l strtok_s、_strtok_s_l、wcstok_s、_wcstok_s_l、_mbstok_s、_mbstok_s_lstrtok_s, _strtok_s_l, wcstok_s, _wcstok_s_l, _mbstok_s, _mbstok_s_l 通过使用当前区域设置或通过的区域设置,查找在字符串中的下一个标记Find the next token in a string, using the current locale or a locale passed in
_strupr、_strupr_l、_mbsupr、_mbsupr_l、_wcsupr_l、_wcsupr_strupr, _strupr_l, _mbsupr, _mbsupr_l, _wcsupr_l, _wcsupr _strupr_s、_strupr_s_l、_mbsupr_s、_mbsupr_s_l、_wcsupr_s、_wcsupr_s_l_strupr_s, _strupr_s_l, _mbsupr_s, _mbsupr_s_l, _wcsupr_s, _wcsupr_s_l 将字符串转换为大写字母Convert a string to uppercase
tmpfiletmpfile tmpfile_stmpfile_s 创建临时文件Create a temporary file
_tempnam、_wtempnam、tmpnam、_wtmpnam_tempnam, _wtempnam, tmpnam, _wtmpnam tmpnam_s、_wtmpnam_stmpnam_s, _wtmpnam_s 生成可用于创建临时文件的名称Generate names you can use to create temporary files
_ultoa、_ultow_ultoa, _ultow _ultoa_s、_ultow_s_ultoa_s, _ultow_s 将无符号长整数转换为字符串Convert an unsigned long integer to a string
_umask_umask _umask_s_umask_s 设置默认的文件权限掩码Set the default file-permission mask
_vcprintf、_vcprintf_l、_vcwprintf、_vcwprintf_l_vcprintf, _vcprintf_l, _vcwprintf, _vcwprintf_l _vcprintf_s、_vcprintf_s_l、_vcwprintf_s、_vcwprintf_s_l_vcprintf_s, _vcprintf_s_l, _vcwprintf_s, _vcwprintf_s_l 使用指向参数列表的指针编写格式化输出到控制台Write formatted output to the console using a pointer to a list of arguments
vfprintf、_vfprintf_l、vfwprintf、_vfwprintf_lvfprintf, _vfprintf_l, vfwprintf, _vfwprintf_l vfprintf_s、_vfprintf_s_l、vfwprintf_s、_vfwprintf_s_lvfprintf_s, _vfprintf_s_l, vfwprintf_s, _vfwprintf_s_l 编写使用指针参数列表的格式化输出Write formatted output using a pointer to a list of arguments
vfscanf、vfwscanfvfscanf, vfwscanf vfscanf_s、vfwscanf_svfscanf_s, vfwscanf_s 从流中读取带格式的数据Read formatted data from a stream
vprintf、_vprintf_l、vwprintf、_vwprintf_lvprintf, _vprintf_l, vwprintf, _vwprintf_l vprintf_s、_vprintf_s_l、vwprintf_s、_vwprintf_s_lvprintf_s, _vprintf_s_l, vwprintf_s, _vwprintf_s_l 编写使用指针参数列表的格式化输出Write formatted output using a pointer to a list of arguments
vscanf、vwscanfvscanf, vwscanf vscanf_s、vwscanf_svscanf_s, vwscanf_s 从标准输入流中读取格式化数据Read formatted data from the standard input stream
vsnprintf、_vsnprintf、_vsnprintf_l、_vsnwprintf、_vsnwprintf_lvsnprintf, _vsnprintf, _vsnprintf_l, _vsnwprintf, _vsnwprintf_l vsnprintf_s、_vsnprintf_s、_vsnprintf_s_l、_vsnwprintf_s、_vsnwprintf_s_lvsnprintf_s, _vsnprintf_s, _vsnprintf_s_l, _vsnwprintf_s, _vsnwprintf_s_l 编写使用指针参数列表的格式化输出Write formatted output using a pointer to a list of arguments
vsprintf、_vsprintf_l、vswprintf、_vswprintf_l、__vswprintf_lvsprintf, _vsprintf_l, vswprintf, _vswprintf_l, __vswprintf_l vsprintf_s、_vsprintf_s_l、vswprintf_s、_vswprintf_s_lvsprintf_s, _vsprintf_s_l, vswprintf_s, _vswprintf_s_l 编写使用指针参数列表的格式化输出Write formatted output using a pointer to a list of arguments
vsscanf、vswscanfvsscanf, vswscanf vsscanf_s、vswscanf_svsscanf_s, vswscanf_s 从字符串中读取格式化数据Read formatted data from a string
wcrtombwcrtomb wcrtomb_swcrtomb_s 将宽字符转换为多字节字符表示形式Convert a wide character into its multibyte character representation
wcsrtombswcsrtombs wcsrtombs_swcsrtombs_s 将宽字符字符串转换为多字节字符串表示形式Convert a wide character string to its multibyte character string representation
wcstombs、_wcstombs_lwcstombs, _wcstombs_l wcstombs_s、_wcstombs_s_lwcstombs_s, _wcstombs_s_l 将宽字符序列转换为对应的多字节字符序列Convert a sequence of wide characters to a corresponding sequence of multibyte characters
wctomb、_wctomb_lwctomb, _wctomb_l wctomb_s、_wctomb_s_lwctomb_s, _wctomb_s_l 将宽字符转换为对应的多字节字符Convert a wide character to the corresponding multibyte character

另请参阅See Also

CRT 库功能CRT Library Features