Help with a string replace function...

I need to clean up some strings that are URL encoded as:

Danny's Best Hits & Oldies

I'd like to be able to replace both ' with a ' and & with an &. There could be both, one or many in the string.

What is the best way to turn that into:

Danny's Best Hits & Oldies

I've been banging my head on this one all day...

The below can do things like that.

http://www.arduino.cc/en/Tutorial/TextString

This is a major hack for your specific purpose that will only work when the string to be inserted (replace) is shorter than the string to find. Luckily this is always the case for URL encoding. It also depends on the implementation of strcpy copying in an upwards direction, which any sane implementation is going to do. ;)

example()
{
  char buf[100];
  strcpy(buf,"Danny's Best Hits & Oldies");

  replaceAll(buf,"'","\'");
  replaceAll(buf,"&","&");
}


void replaceAll(char *buf_,const char *find_,const char *replace_)
{
  char *pos;
  int replen,findlen;
      
  findlen=strlen(find_);
  replen=strlen(replace_);
      
  while((pos=strstr(buf_,find_)))
  {
    strncpy(pos,replace_,replen);
    strcpy(pos+replen,pos+findlen);
  }
}