X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstring%2Fstrcspn.c;h=70b978824e7d6973df4a393c678aad6cb47daad5;hb=7832fa07b60f2176efd9e9e4746246717d3e8949;hp=80c620cb03c8749e514c7d81caefd9372ce5a01b;hpb=34893ecc2200dc7017c36a54cb6c5f4c2378b5ec;p=pdclib diff --git a/functions/string/strcspn.c b/functions/string/strcspn.c index 80c620c..70b9788 100644 --- a/functions/string/strcspn.c +++ b/functions/string/strcspn.c @@ -5,4 +5,23 @@ // This code is Public Domain. Use, modify, and redistribute at will. // ---------------------------------------------------------------------------- -size_t strcspn( const char * s1, const char * s2 ) { /* TODO */ }; +#include <__size_t.h> + +size_t strcspn( const char * src_1, const char * src_2 ) +{ + size_t len = 0; + const char * src_p; + while ( src_1[len] != '\0' ) + { + src_p = src_2; + while ( *src_p != '\0' ) + { + if ( src_1[len] == *src_p++ ) + { + return len; + } + } + ++len; + } + return len; +}