插入字符串问题,到后面不知道该怎么插进去

问题遇到的现象和发生背景
用代码块功能插入代码,请勿粘贴截图
我想要达到的结果

img

#include
#include
int main()
{ char a[100],t,m;
  char b[10];
  b[10]={"max"};
  scanf("%s",&a[100]);
  lena=strlen(a);
  lenb=strlen(b);
  m=a[0];
  for(i=0;i<100;i++)
  { if(mfor(j=0;i<100;j++)
     { if(a[j]==m)
       { 
       }
     }
    }
    
  }
    return 0;
 } 


#include <string.h>
#include <stdio.h>

int main()
{
    char str[100] = {0}, max = 0, rst[500] = {0};
    fgets(str, 100, stdin);
    int i = 0, j;
    while (str[i] != '\n')
    {
        if (str[i] > max) //找到最大字符
            max = str[i];
        i++;
    }

    i = j = 0;
    while (str[i] != '\n')
    {
        rst[j++] = str[i]; //
        if (str[i] == max) //遇到最大字符,拼接"max"
        {
            strcat(rst + j, "\"max\"");
            j += 5;
        }
        i++;
    }
    puts(rst);

    return 0;
}