C언어 strspn()

1 개요[ | ]

C언어 strspn()
문자열 구성에 어긋나는 위치 찾기
일치하지 않는 첫 번째 문자의 오프셋 찾기
  • 구성에 어긋나는 것이 없으면 마지막까지 탐색하여 문자열의 길이과 같은 결과가 됨
#include <stdio.h>
#include <string.h>
 
int main() {
    printf( "%d\n", strspn("foo", "") ); // 0
    printf( "%d\n", strspn("foo", "o") ); // 0
    printf( "%d\n", strspn("foo", "of") ); // 3
    printf( "%d\n", strspn("bar", "ab") ); // 2
    printf( "%d\n", strspn("cabbage.", "abc") ); // 5
    printf( "%d\n", strspn("hi there.", "hit me") ); // 6
    printf( "%d\n", strspn("42 is the answer", "1234567890") ); // 2
}

2 같이 보기[ | ]

3 참고[ | ]

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