1 개념[ | ]
- C언어 memset()
- 바이트 크기의 값을 가지고 바이트 문자를 채움
2 문법[ | ]
헤더
C
Copy
string.h
정의
C
Copy
void *memset(void *b, int c, size_t len);
- →len 길이만큼 c(unsigned char로 형 변환)의 문자로 포인터 b로 시작하는 문자열의 문자들을 대치함.
3 예시[ | ]
C
Copy
#include <stdio.h>
#include <string.h>
int main()
{
char str[] = "John is my name.";
memset(str, '*', 4);
printf("%s", str); // **** is my name.
}
- → "John is my name.에서 처음 4개 문자를 '*'로 대체
4 같이 보기[ | ]
편집자 John Jeong Jmnote bot Jmnote
로그인하시면 댓글을 쓸 수 있습니다.
- 분류 댓글:
- C (7)
C, C++ 주석 ― YkhwongC, C++ 주석 ― John JeongC, C++ 주석 ― JmnoteC, C++ 주석 ― John JeongC언어 연결리스트 구현 ― 돌멩이C언어 연결리스트 구현 ― John JeongC언어 연결리스트 구현 ― 돌멩이