_strset_s, _strset_s_l, _wcsset_s, _wcsset_s_l, _mbsset_s, _mbsset_s_l

문자열의 문자를 특정 문자로 설정합니다. CRT_strset_l_strset보안 기능에 설명된 대로 이러한 버전의 < _mbsset_l_wcsset_wcsset_l_mbsset a0/>에는 보안 기능이 향상되었습니다.

Important

Windows 런타임에서 실행되는 애플리케이션에서는 _mbsset_s_mbsset_s_l을 사용할 수는 없습니다. 자세한 내용은 유니버설 Windows 플랫폼 앱에서 지원되지 않는 CRT 함수를 참조하세요.

구문

errno_t _strset_s(
   char *str,
   size_t numberOfElements,
   int c
);
errno_t _strset_s_l(
   char *str,
   size_t numberOfElements,
   int c,
   _locale_t locale
);
errno_t _wcsset_s(
   wchar_t *str,
   size_t numberOfElements,
   wchar_t c
);
errno_t *_wcsset_s_l(
   wchar_t *str,
   size_t numberOfElements,
   wchar_t c,
   _locale_t locale
);
errno_t _mbsset_s(
   unsigned char *str,
   size_t numberOfElements,
   unsigned int c
);
errno_t _mbsset_s_l(
   unsigned char *str,
   size_t numberOfElements,
   unsigned int c,
   _locale_t locale
);

매개 변수

str
설정할 Null 종료 문자열입니다.

numberOfElements
str 버퍼의 크기입니다.

c
문자 설정입니다.

locale
사용할 로캘입니다.

반환 값

정상적으로 실행되는 경우 0이고 그렇지 않으면 오류 코드입니다.

이러한 함수는 해당 인수의 유효성을 검사합니다. null 포인터이거나 numberOfElements 인수가 0보다 작거나 같거나 전달된 블록이 null로 종료되지 않은 경우 str 매개 변수 유효성 검사에 설명된 대로 잘못된 매개 변수 처리기가 호출됩니다. 계속해서 실행하도록 허용된 경우, 이러한 함수는 EINVAL를 반환하고 errnoEINVAL로 설정합니다.

설명

_strset_s 함수는 종료 null 문자를 제외한 str의 모든 문자를 char로 변환된 c로 설정합니다. _wcsset_s_mbsset_s_strset_s의 와이드 문자 및 멀티바이트 문자 버전입니다. 인수 및 반환 값의 데이터 형식은 버전에 따라 달라집니다. 그 외의 경우에는 이들 함수가 동일하게 작동합니다.

출력 값은 로캘의 LC_CTYPE 범주 설정 설정의 영향을 받습니다. 자세한 내용은 setlocale를 참조하세요. _l 접미사가 없는 이러한 함수 버전은 이 로캘 종속 동작에 현재 로캘을 사용하며, _l 접미사가 있는 버전은 전달된 로캘 매개 변수를 대신 사용하는 경우를 제외하고는 동일합니다. 자세한 내용은 Locale을 참조하세요.

이러한 함수의 디버그 라이브러리 버전은 먼저 버퍼를 0xFE 채웁니다. 이 동작을 사용하지 않도록 설정하려면 .를 사용합니다 _CrtSetDebugFillThreshold.

기본적으로 이 함수의 전역 상태는 애플리케이션으로 범위가 지정됩니다. 이 동작을 변경하려면 CRT의 전역 상태를 참조하세요.

일반 텍스트 루틴 매핑

TCHAR.H 루틴 _UNICODE 정의 _MBCS 되지 않음 _MBCS 정의 _UNICODE 정의
_tcsset_s _strset_s _mbsset_s _wcsset_s
_tcsset_s_l _strset_s_l _mbsset_s_l _wcsset_s_l

요구 사항

루틴에서 반환된 값 필수 헤더
_strset_s <string.h>
_strset_s_l <tchar.h>
_wcsset_s <string.h> 또는 <wchar.h>
_wcsset_s_l <tchar.h>
_mbsset_s, _mbsset_s_l <mbstring.h>

호환성에 대한 자세한 내용은 호환성을 참조하세요.

예시

// crt_strset_s.c
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

int main( void )
{
   char string[] = "Fill the string with something.";
   printf( "Before: %s\n", string );
   _strset_s( string, _countof(string), '*' );
   printf( "After:  %s\n", string );
}
Before: Fill the string with something.
After:  *******************************

참고 항목

문자열 조작
Locale
멀티바이트 문자 시퀀스 해석
_mbsnbset, _mbsnbset_l
memset, wmemset
strcat, wcscat, _mbscat
strcmp, wcscmp, _mbscmp
strcpy, wcscpy, _mbscpy
_strnset, _strnset_l, _wcsnset, _wcsnset_l, _mbsnset, _mbsnset_l