StrOps::Words( StrBuf &, const char *[], char *[], int )
Break a string apart at whitespace.
Virtual? |
No |
|
Class |
||
Arguments |
|
a temporary string |
|
the input string |
|
|
the output array |
|
|
the maximum number of words to handle |
|
Returns |
|
the actual number of words handled |
Notes
This function uses the isAspace()
function to define
whitespace.
Example
StrBuf o = StrBuf(); StrBuf tmp = StrBuf(); o.Set( "abc\tdef ghi\nxyz xyzzy plugh" ); printf( "Input StrBuf:\n%s\n", o.Text() ); char *vec[5]; int w = StrOps::Words( tmp, o, vec, 5 ); for ( ; w ; w-- ) { printf( "Word %d: %s\n", w, vec[w-1] ); } return 0;
Executing the preceding code produces the following output:
Input StrBuf: abc def ghi xyz xyzzy plugh Word 5: xyzzy Word 4: xyz Word 3: ghi Word 2: def Word 1: abc