C언어 strtok()

Jmnote bot (토론 | 기여)님의 2020년 11월 2일 (월) 02:41 판 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

C언어 strtok()
  • 문자열 토큰화 함수
#include <string.h>
char *strtok(char *string1, const char *string2);

2 예시[ | ]

#include <stdio.h>
#include <string.h>
 
int main() {
    char string[] = "a string, of, ,tokens\0,after null terminator";
    char *token;
    token = strtok(string, ",");
    do {
        printf("token: [%s]\n", token);
    }
    while( token = strtok(NULL, ",") );
}
// token: [a string]
// token: [ of]
// token: [ ]
// token: [tokens]

3 같이 보기[ | ]

4 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}