codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include<iostream.h> char *strtok_new(char * string, char const * delimiter){ static char *source = NULL; char *p, *riturn = 0; if(string != NULL) source = string; if(source == NULL) return NULL; if((p = strpbrk (source, delimiter)) != NULL) { *p = 0; riturn = source; source = ++p; } return riturn; } int main(){ char string[] = "one,,three,"; char delimiter[] = ","; char * p = strtok_new(string, delimiter); while(p){ if(*p) cout << p << endl; else cout << "No data" << endl; p = strtok_new(NULL, delimiter); } system("pause"); return 0; }
Private
[
?
]
Run code
Submit