Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char **all_rotations(const char *str)
- {
- char *buf, **rots;
- int len = strlen(str), i;
- buf = calloc(2*len+1, sizeof(char));
- strcpy(buf, str);
- strcpy(buf+strlen(str), str);
- rots = malloc(len * sizeof(char*));
- for (i = 0; i < len; ++i) {
- rots[i] = calloc(len+1, sizeof(char));
- strncpy(rots[i], buf+i, len);
- }
- free(buf);
- return rots;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement