Advertisement
NovaYoshi

TextInterpolate

Jul 18th, 2015
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  1. void TextInterpolate(char *Out, const char *In, char Prefix, const char *ReplaceThis, const char *ReplaceWith[]) {
  2.   while(*In) {
  3.     if(*In != Prefix)
  4.       *(Out++) = *(In++);
  5.     else {
  6.       In++;
  7.       char *Find = strchr(ReplaceThis, *(In++));
  8.       if(Find) {
  9.         int This = Find - ReplaceThis;
  10.         strcpy(Out, ReplaceWith[This]);
  11.         Out += strlen(ReplaceWith[This]);
  12.       } else {
  13.         *(Out++) = Prefix;
  14.         *(Out++) = In[-1];
  15.       }
  16.     }
  17.   }
  18.   *Out = 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement