"John Sutton" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Off the top of my head, isn't it as simple as passing a pointer to the string to something like this (assuming they're all single byte characters)... void MyStringReverse(char *s) { long iLo,iHi; char cSwap; iLo=0; iHi=StrLen(s)-1; while(iHi>iLo) { cSwap=s[iLo]; s[iLo]=s[iHi]; s[iHi]=cSwap; iLo++; iHi--; } }
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Palm Dev Sent: 02 March 2005 14:37 To: Palm Developer Forum Subject: Re: "Reverse" Function it is not implemented, at least in the release which im using (codewarrior 9.3 with Palm SDK 5). -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/ It IS trivial, but you can shoot yourself in the foot. If the source string is a literal string, then you had better not reverse in place. Hence returning a dynamic string or a string in a static buffer or a buffer supplied by the caller (not done in standard implementations). Here is one version from the web: #include <stdio.h> /* strrev.c */ #include <string.h> #include <stdlib.h> char * strrev(char * string) { int length = strlen(string); char * result = malloc(length+1); if( result != NULL ) { int i,j; result[length] = '\0'; for ( i = length-1, j=0; i >= 0; i--, j++ ) result[j] = string[i]; } return result; } The dynamic string needs to be freed, a static string will have a max length limitation. Just google "strrev.c". This is more a standard C question than a Palm related question. Ralph -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
