Security-Enhanced Versions of CRT Functions

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at Security-Enhanced Versions of CRT Functions.

More secure versions of run-time library routines are available. For further information concerning Security Enhancements in the CRT, see Security Features in the CRT.

Secure Functions

CRT FunctionSecurity enhanced functionUse
_access, _waccess_access_s, _waccess_sDetermine file-access permission
_alloca_mallocaAllocate memory on the stack
asctime, _wasctimeasctime_s, _wasctime_sConvert time from type struct tm to character string
bsearchbsearch_sPerform a binary search of a sorted array
Obsolete function_cgets_s, _cgetws_sGet a character string from the console
_chsize_chsize_sChange the size of a file
clearerrclearerr_sReset the error indicator for a stream
_control87, _controlfp, __control87_2_controlfp_sGet and set the floating-point control word
_cprintf, _cprintf_l, _cwprintf, _cwprintf_l_cprintf_s, _cprintf_s_l, _cwprintf_s, _cwprintf_s_lFormat and print to the console
_cscanf, _cscanf_l, _cwscanf, _cwscanf_l_cscanf_s, _cscanf_s_l, _cwscanf_s, _cwscanf_s_lRead formatted data from the console
ctime, _ctime32, _ctime64, _wctime, _wctime32, _wctime64_ctime_s, _ctime32_s, _ctime64_s, _wctime_s, _wctime32_s, _wctime64_sConvert time from type time_t, __time32_t or __time64_t to character string
_ecvt_ecvt_sConvert a double number to a string
_fcvt_fcvt_sConverts a floating-point number to a string
fopen, _wfopenfopen_s, _wfopen_sOpen a file
fprintf, _fprintf_l, fwprintf, _fwprintf_lfprintf_s, _fprintf_s_l, fwprintf_s, _fwprintf_s_lPrint formatted data to a stream
freadfread_sRead from a file
_fread_nolock_fread_nolock_sRead from a file without using a multi-thread write lock
freopen, _wfreopenfreopen_s, _wfreopen_sReopen the file
fscanf, _fscanf_l, fwscanf, _fwscanf_lfscanf_s, _fscanf_s_l, fwscanf_s, _fwscanf_s_lRead formatted data from a stream
_ftime, _ftime32, _ftime64_ftime_s, _ftime32_s, _ftime64_sGet the current time
_gcvt_gcvt_sConvert a floating-point value to a string, and store it in a buffer
getenv, _wgetenvgetenv_s, _wgetenv_sGet a value from the current environment.
Obsolete functiongets_s, _getws_sGet a line from the stdin stream
gmtime, _gmtime32, _gmtime64_gmtime32_s, _gmtime64_sConvert time from type time_t to struct``tm or from type __time64_t to struct tm
_itoa, _i64toa, _ui64toa, _itow, _i64tow, _ui64tow_itoa_s, _i64toa_s, _ui64toa_s, _itow_s, _i64tow_s, _ui64tow_sConvert an integer to a string
_lfind_lfind_sPerform a linear search for the specified key
localtime, _localtime32, _localtime64localtime_s, _localtime32_s, _localtime64_sConvert time from type time_t to struct tm or from type __time64_t to struct tmwith local correction
_lsearch_lsearch_sPerform a linear search for a value; adds to end of list if not found
_ltoa, _ltow_ltoa_s, _ltow_sConvert a long integer to a string
_makepath, _wmakepath_makepath_s, _wmakepath_sCreate a path name from components
_mbccpy, _mbccpy_l_mbccpy_s, _mbccpy_s_lCopy a multibyte character from one string to another string
_mbsnbcat, _mbsnbcat_l_mbsnbcat_s, _mbsnbcat_s_lAppend, at most, the first n bytes of one multibyte character string to another
_mbsnbcpy, _mbsnbcpy_l_mbsnbcpy_s, _mbsnbcpy_s_lCopy n bytes of a string to a destination string
_mbsnbset, _mbsnbset_l_mbsnbset_s, _mbsnbset_s_lSet the first n bytes of a string to a specified character
mbsrtowcsmbsrtowcs_sConvert a multibyte character string to a corresponding wide character string
mbstowcs, _mbstowcs_lmbstowcs_s, _mbstowcs_s_lConvert a sequence of multibyte characters to a corresponding sequence of wide characters
memcpy, wmemcpymemcpy_s, wmemcpy_sCopy characters between buffers
memmove, wmemmovememmove_s, wmemmove_sMove one buffer to another
_mktemp, _wmktemp_mktemp_s, _wmktemp_sCreate a unique filename
printf, _printf_l, wprintf, _wprintf_lprintf_s, _printf_s_l, wprintf_s, _wprintf_s_lPrint formatted output to the standard output stream
_putenv, _wputenv_putenv_s, _wputenv_sCreate, modify, or remove environment variables
qsortqsort_sPerform a quick sort
randrand_sGenerate a pseudorandom number
scanf, _scanf_l, wscanf, _wscanf_lscanf_s, _scanf_s_l, wscanf_s, _wscanf_s_lRead formatted data from the standard input stream
_searchenv, _wsearchenv_searchenv_s, _wsearchenv_sSearch for a file using environment paths
snprintf, _snprintf, _snprintf_l, _snwprintf, _snwprintf_l_snprintf_s, _snprintf_s_l, _snwprintf_s, _snwprintf_s_lWrite formatted data to a string
_snscanf, _snscanf_l, _snwscanf, _snwscanf_l_snscanf_s, _snscanf_s_l, _snwscanf_s, _snwscanf_s_lRead formatted data of a specified length from a string.
_sopen, _wsopen_sopen_s, _wsopen_sOpen a file for sharing
_splitpath, _wsplitpath_splitpath_s, _wsplitpath_sBreak a path name into components
sprintf, _sprintf_l, swprintf, _swprintf_l, __swprintf_lsprintf_s, _sprintf_s_l, swprintf_s, _swprintf_s_lWrite formatted data to a string
sscanf, _sscanf_l, swscanf, _swscanf_lsscanf_s, _sscanf_s_l, swscanf_s, _swscanf_s_lRead formatted data from a string
strcat, wcscat, _mbscatstrcat_s, wcscat_s, _mbscat_sAppend a string
strcpy, wcscpy, _mbscpystrcpy_s, wcscpy_s, _mbscpy_sCopy a string
_strdate, _wstrdate_strdate_s, _wstrdate_sReturn current system date as string
strerror, _strerror, _wcserror, __wcserrorstrerror_s, _strerror_s, _wcserror_s, __wcserror_sGet 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_s, _strlwr_s_l, _mbslwr_s, _mbslwr_s_l, _wcslwr_s, _wcslwr_s_lConvert a string to lowercase
strncat, _strncat_l, wcsncat, _wcsncat_l, _mbsncat, _mbsncat_lstrncat_s, _strncat_s_l, wcsncat_s, _wcsncat_s_l, _mbsncat_s, _mbsncat_s_lAppend characters to a string
strncpy, _strncpy_l, wcsncpy, _wcsncpy_l, _mbsncpy, _mbsncpy_lstrncpy_s, _strncpy_s_l, wcsncpy_s, _wcsncpy_s_l, _mbsncpy_s, _mbsncpy_s_lCopy characters of one string to another
_strnset, _strnset_l, _wcsnset, _wcsnset_l, _mbsnset, _mbsnset_l_strnset_s, _strnset_s_l, _wcsnset_s, _wcsnset_s_l, _mbsnset_s, _mbsnset_s_lSet the first n characters of a string to the specified character
_strset, _strset_l, _wcsset, _wcsset_l, _mbsset, _mbsset_l_strset_s, _strset_s_l, _wcsset_s, _wcsset_s_l, _mbsset_s, _mbsset_s_lSet all the characters of a string to the specified character
_strtime, _wstrtime_strtime_s, _wstrtime_sReturn current system time as string
strtok, _strtok_l, wcstok, _wcstok_l, _mbstok, _mbstok_lstrtok_s, _strtok_s_l, wcstok_s, _wcstok_s_l, _mbstok_s, _mbstok_s_lFind 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_s, _strupr_s_l, _mbsupr_s, _mbsupr_s_l, _wcsupr_s, _wcsupr_s_lConvert a string to uppercase
tmpfiletmpfile_sCreate a temporary file
_tempnam, _wtempnam, tmpnam, _wtmpnamtmpnam_s, _wtmpnam_sGenerate names you can use to create temporary files
_ultoa, _ultow_ultoa_s, _ultow_sConvert an unsigned long integer to a string
_umask_umask_sSet the default file-permission mask
_vcprintf, _vcprintf_l, _vcwprintf, _vcwprintf_l_vcprintf_s, _vcprintf_s_l, _vcwprintf_s, _vcwprintf_s_lWrite formatted output to the console using a pointer to a list of arguments
vfprintf, _vfprintf_l, vfwprintf, _vfwprintf_lvfprintf_s, _vfprintf_s_l, vfwprintf_s, _vfwprintf_s_lWrite formatted output using a pointer to a list of arguments
vfscanf, vfwscanfvfscanf_s, vfwscanf_sRead formatted data from a stream
vprintf, _vprintf_l, vwprintf, _vwprintf_lvprintf_s, _vprintf_s_l, vwprintf_s, _vwprintf_s_lWrite formatted output using a pointer to a list of arguments
vscanf, vwscanfvscanf_s, vwscanf_sRead formatted data from the standard input stream
vsnprintf, _vsnprintf, _vsnprintf_l, _vsnwprintf, _vsnwprintf_lvsnprintf_s, _vsnprintf_s, _vsnprintf_s_l, _vsnwprintf_s, _vsnwprintf_s_lWrite formatted output using a pointer to a list of arguments
vsprintf, _vsprintf_l, vswprintf, _vswprintf_l, __vswprintf_lvsprintf_s, _vsprintf_s_l, vswprintf_s, _vswprintf_s_lWrite formatted output using a pointer to a list of arguments
vsscanf, vswscanfvsscanf_s, vswscanf_sRead formatted data from a string
wcrtombwcrtomb_sConvert a wide character into its multibyte character representation
wcsrtombswcsrtombs_sConvert a wide character string to its multibyte character string representation
wcstombs, _wcstombs_lwcstombs_s, _wcstombs_s_lConvert a sequence of wide characters to a corresponding sequence of multibyte characters
wctomb, _wctomb_lwctomb_s, _wctomb_s_lConvert a wide character to the corresponding multibyte character

CRT Library Features

Show: