title: How to replace substring with int
body: <p>So i've seen alot of functions like str_replace(str, substr, newstring) but all of them won't work with numbers so i was wondering if anyone had one that would work with both chars and ints or just int ive been looking everywhere and cant figure out a idea on how to write my own.
  my goal exactly is to be able to replace a string with a int value in the string not just string with string</p>
  <p>below is the function i use to replace strings and it worked just fine</p>
  <pre><code>void strrpc(char *target, const char *needle, const char *replacement)
  {
      char buffer[1024] = { 0 };
      char *insert_point = &amp;buffer[0];
      const char *tmp = target;
      size_t needle_len = strlen(needle);
      size_t repl_len = strlen(replacement);
  
      while (1) {
          const char *p = strstr(tmp, needle);
  
          // walked past last occurrence of needle; copy remaining part
          if (p == NULL) {
              strcpy(insert_point, tmp);
              break;
          }
  
          // copy part before needle
          memcpy(insert_point, tmp, p - tmp);
          insert_point += p - tmp;
  
          // copy replacement string
          memcpy(insert_point, replacement, repl_len);
          insert_point += repl_len;
  
          // adjust pointers, move on
          tmp = p + needle_len;
      }
  
      // write altered string back to target
      strcpy(target, buffer);
  }
  </code></pre>