:
This message was edited by tokoG at 2006-3-30 23:34:2
:
: Hi!
:
: I came accross the new string function, strspn and checked what it does.
: This site had pretty good explanation
http://www.cplusplus.com/ref/cstring/strspn.html but, all in all, I think what it does is return the number(length) of what it matches to the other string.
:
:
In here, strtext & cset both contains 1 & 2 & 9, that's why the return is 3. Am I right?
:
: /* strspn example */
: #include <stdio.h>
: #include <string.h>
:
: int main ()
: {
: int i;
: char strtext[] = "129th";
: char cset[] = "1234567890";
:
: i = strspn (strtext,cset);
: printf ("Length of initial number is %d\n",i);
: return 0;
: }
:
: Output:
: Length of initial number is 3
:
:
: I don't know how this could be useful..?
:
:
:
:
:
From MSDN:
Returns the index of the first character in a string that does not belong to a set of characters.
In your example, the letter 't' in "129th" is the first character that does not occur in the string "1234567890".
The 't' is at position 3 (zero based) in "129th", that's why the return value is 3.
Greets,
Eric Goldstein
www.gvh-maatwerk.nl