Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- void semiTokenizer (char *token, char *string)
- {
- int i = 0, ti = 0;
- int y;
- //remove spaces before first token...
- while ( string[i] == ' ' )
- i++;
- //get first token...
- while ( string[i] != ' ' && string[i] != '\0' )
- {
- if ( string[i] == '"' ) {
- for ( i = i + 1 ; string[i] != '\0' ; i++ ) {
- if( string[i] == '"' && (string[i + 1] == ' ' || string[i + 1] == '\0') ) {
- i++;
- break;
- }
- token[ti++] = string[i];
- }
- } else {
- token[ti++] = string[i];
- i++;
- }
- }
- token[ti] = '\0';
- //remove "token" from original string...
- y = 0;
- while ( i < (strlen(string) + 1) ) {
- string[y++] = string[i++];
- }
- }
- int main(void)
- {
- char commandline[100];
- char tuken[25];
- int i = 0;
- gets(commandline);
- do {
- semiTokenizer(tuken, commandline);
- cout << tuken << endl;
- } while ( strlen(tuken) );
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement