Skip to content

Instantly share code, notes, and snippets.

@ror3d
Forked from anonymous/split.cpp
Created September 27, 2012 10:04
Show Gist options
  • Save ror3d/3793249 to your computer and use it in GitHub Desktop.
Save ror3d/3793249 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] = 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