-
-
Save ror3d/3793249 to your computer and use it in GitHub Desktop.
Argument Splitter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
char ** split(const string & str, int arguments){ | |
char ** argv; | |
argv = new char * [arguments]; | |
uint index = 0; | |
int offset = 0; | |
int argcount = 0; | |
do{ | |
index = 0; | |
while (str[index + offset] != ' ' && index + offset < str.length()){ | |
index ++; | |
} | |
argv[argcount] = strcpy(new char [str.length()+1], str.substr(offset,index).c_str()); | |
offset += index + 1; | |
argcount += 1; | |
} while (index + offset < str.length()); | |
return argv; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment