string tokenize
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #include <stdio.h> char* String_Tokenize(char* String, char const* _Delimiter); int main(void) { char String[30] = "The Little Prince"; char* pointer = String_Tokenize(String, " "); while (pointer != (char)0) { printf("%s\n", pointer); pointer = String_Tokenize((char)0, " "); } return 0; } char* String_Tokenize(char* _String, char const* _Delimiter) { char static* String = (char)0; char const* Delimiter = (char)0; if (_String == (char)0) { _String = String; } else { String = _String; } if (*_String == (char)0) return (char)0; while (*String) { Delimiter = _Delimiter; while (*Delimiter) { if (*String == *Delimiter) { *String = (char)0; String++; return _String; } Delimiter++; } String++; } return _String; } | cs |
0 개의 댓글:
댓글 쓰기