在oj系统中提交老是出现Runtime Error,怎么修改也不行,求指点

Description
给定两个字符串,将它们连接起来。不得使用strcat函数。

Input
测试数据有多组,第一行的正整数T表示测试数据的组数。每组有两个字符串,分别占两行,每个字符串不超过100个字符。

Output
对于每组测试数据,输出连接后的字符串,单独占一行。

Sample Input
2
abc
1234
xy
oop
Sample Output
abc1234
xyoop

#include<stdio.h>
#define M 100
int main()
{
    char a1[M],a2[M];
    int t,i1;
    scanf("%d",&t);
    for(i1=0;i1<t;i1++)
    {
        getchar();
        int j=0;
        a1[j]=getchar();
        while(a1[j]!='\n')
        {
            j++;
            a1[j]=getchar();
        }
        static int i=0;
        a2[i]=getchar();
        while((a1[j]=a2[i])!='\n')
        {
            i++,j++;
            a2[i]=getchar();
        }
        a1[j]='\0';
        for(j=0;a1[j]!='\0';j++)
        printf("%c",a1[j]);
    }
    return 0;
}

https://blog.csdn.net/sunshineacm/article/details/79871953