Greetings,

I myself am rather new to string manipulation.  But would something
like this work?

char *new_smash_tilde (const char *str)
{
 static char newbuf[MSL];
 int count;

 for (count = 0 ; *str != '\0'; str++, count++)
 {
    if (*str == '~')
    {
      newbuf[count] = '&';
      count++;
      newbuf[count] = '-';
    }
    else
      newbuf[count] = *str;
 }

 count++;
 newbuf[count] = '\0';

 return newbuf;
}

Of course, you'd need to call something like
  string = new_smash_tilde(string);

instead of the way the original is called.

If there is an easier/more elegant way to do this I'm all ears :).

Also, quick question.  In the loop, is it possible to just do a
  newbuf[++count] = '-';
Instead of incrementing the counter on a seperate line?  I seem to
recall seeing this done somewhere but it returned an error.

Good luck :)

Brett


Hi,

I would like to change the following function to replace the tilde letter to
the two letters "&-" which is my color code for the tilde letter. Right now
it can only replace the letter with another letter. What what I do to this
function to be able to replace the tilde letter with two letters? I'm new to
string manipulation. =P


_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail


Reply via email to