[AD] Reverse String function...

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Hi  guys,working on a program , i needed a reverse string function...i
watched out to allegro string API, but i didn't find anything, so i had to
develop it by byself.
Why don't add a function like this to Allegro?
It reverses nchar characters from the start of the string s returning the
pointer to reversed string
What do you think?

Carmelo Maiolino
----------------------------------------------------------------------------
------------------------>
char * ureverse(char *s,int nchar)
{
   char szDest[255];
   char *pszDest=szDest;
   char tmp;
   int k;
   ustrcpy(pszDest, s);
   if (nchar<0) nchar=0;
   if (nchar>ustrlen(s)) nchar=ustrlen(s);
   for(k=0;k<(nchar/2);k++)
  {
    tmp=*(pszDest+k);
    *(pszDest+k)=*(pszDest+(nchar-(k+1)));
    *(pszDest+(nchar-(k+1)))=tmp;
  }
  return (pszDest);
}

----------------------------------------------------------------------------
--------------------------->



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/