Skip to content

Instantly share code, notes, and snippets.

Created September 27, 2012 10:00
Show Gist options
  • Save anonymous/3793238 to your computer and use it in GitHub Desktop.
Save anonymous/3793238 to your computer and use it in GitHub Desktop.
Argument Splitter
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] = (char *) 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