C_C++/C_라이브러리_함수

(C언어) strnset: 문자열을 주어진 문자로 초기화한다

고니자니 2023. 3. 7. 09:02
반응형
#include<string.h>
char *strnset(char *s, int ch, size_t n);

strnset 함수는 문자열을 n 크기만큼  주어진 문자로 초기화합니다.

Initializes characters of a string to a given character.

 

비주얼스튜디어에서는 strnset 함수 대신에 _strnset 함수를 사용해야 합니다.

 

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
int main() 
{
	char s[]= "Initializes characters of a string to a given character.";
	
	_strnset(s, 'x', strlen(s));
	printf("%s\n", s);
		
	return 0;
}

setnset: 문자열을 특정 문자로 초기화한다

 

728x90
반응형