Skip to content

Instantly share code, notes, and snippets.

@jermenkoo
Last active November 25, 2015 22:54
Show Gist options
  • Save jermenkoo/cb6748ece4d97fc849d5 to your computer and use it in GitHub Desktop.
Save jermenkoo/cb6748ece4d97fc849d5 to your computer and use it in GitHub Desktop.
char* segment(char *g, int m, int n) {
char *r = (char*) malloc((n - m + 1) * sizeof(char));
char *temp = g;
temp += m;
while (m != n) {
r[m] = temp[m];
m++;
}
r[m] = '\0';
return r;
}
//segment("testtest", 0, 4) -> "test"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment