바야바네 움집
[정리] 문자열 : strtok 본문
- strtok 함수는 포인터를 반환한다.
- 문자열을 한 번 제공해주면 그 문자열을 다 자르기 전까지는 문자열을 다시 줄 필요가 없음. (This function is designed to be called multiple times to obtain successive tokens from the same string.)
/* strtok example */
#include <stdio.h>
#include <string.h>
int main ()
{
char str[] ="- This, a sample string.";
char * pch;
printf ("Splitting string \"%s\" into tokens:\n",str);
pch = strtok (str," ,.-");
while (pch != NULL)
{
printf ("%s\n",pch);
pch = strtok (NULL, " ,.-");
}
return 0;
}
https://en.cppreference.com/w/cpp/string/byte/strtok
std::strtok - cppreference.com
char* strtok( char* str, const char* delim ); Finds the next token in a null-terminated byte string pointed to by str. The separator characters are identified by null-terminated byte string pointed to by delim. This function is designed to be called multip
en.cppreference.com
https://www.cplusplus.com/reference/cstring/strtok/?kw=strtok
strtok - C++ Reference
Splitting string "- This, a sample string." into tokens: This a sample string
www.cplusplus.com
https://blockdmask.tistory.com/382
[C언어/C++] strtok 함수(문자열 자르기)에 대해서.
안녕하세요. BlockDMask 입니다. 오늘 공부할 함수는 문자열을 일정 기준을 정해서 싹둑싹둑 자를 수 있는 strtok 함수입니다. C언어 strtok 함수에 대해서 한번 알아보러 가보겠습니다. <목차> 1. strtok
blockdmask.tistory.com
'📘C++' 카테고리의 다른 글
[Geeksforgeeks] Given an array A[] and a number x, check for pair in A[] with sum as x (0) | 2021.11.24 |
---|---|
printf()로 string 변수 출력하기 (0) | 2021.11.23 |