AceInfinity
Emeritus, Contributor
Just a random thread where I can post some functions useful for string manipulation:
Others may post their snippets and functions here as well if they desire :)
Code:
[NO-PARSE]/* description: circular rotation of string [src] by [n] count.
* returns: [src]
----------------------------------------------------------------- */
char *rotstr_l(char *src, int n)
{
int i, ch;
for (i = 0; i < n; ++i)
{
ch = *src;
memmove(src, src + 1, strlen(src));
src[strlen(src)] = ch;
}
return src;
}
/* description: circular rotation of string [src] by [n] count.
* returns: [src]
----------------------------------------------------------------- */
char *rotstr_r(char *src, int n)
{
int i, ch;
for (i = 0; i < n; ++i)
{
ch = src[strlen(src) - 1];
memmove(src + 1, src, strlen(src) - 1);
*src = ch;
}
return src;
}
[/NO-PARSE]
Others may post their snippets and functions here as well if they desire :)
Last edited: