strcpy用法问题


void my_fputc(char *path)
{
    if (path == NULL)
    {
        return;
    }

    FILE* fp;

    fp = fopen(path, "w+");

    if (fp == NULL)
    {
        perror("fopen");
        system("pause");
        return;
    }

    char buf[] = "this is test";
    char tmp1[20] = { 0 };
    char tmp2[20] = "lyyyw";
    int i = 0;
    int n = strlen(buf);

    for (i = 0; i < n; i++)
    {
        int ret = fputc(buf[i],fp);
        sprintf(tmp1,"%c",ret);
        strcpy(tmp2[i],tmp1[0]);
        //printf("%c", ret);
    }

    if (fp != NULL)
    {
        fclose(fp);
        fp = NULL;
    }
}

void my_fgetc(char* path)
{
    FILE* fp;

    fp = fopen(path, "r+");

    char ch;

    if (fp == NULL)
    {
        perror("fopen");
        system("pause");
        return;
    }

    //while ((ch = fgetc(fp)) != EOF)
    while(!feof(fp))
    {
        ch = fgetc(fp);
        printf("%c",ch);
    }

    if (fp != NULL)
    {
        fclose(fp);
        fp = NULL;
    }
}

int main(void)
{
    my_fputc("../test.txt");

    //my_fgetc("../test.txt");

    printf("\n");
    system("pause");
}

为什么这种情况下strcpy会出现错误,两个变量都是有内存的

strcpy(tmp2[i],tmp1[0]);

strcpy拷贝的是字符串,不是字符

strcpy参数是指针

strcpy(tmp2, tmp1);

strcpy()传参类型是char*,不能穿char类型