comment retourner un tableau de caractères d'une fonction dans C

Je souhaite retourner un tableau de caractères à partir d'une fonction. Alors je veux l'imprimer en main. comment puis-je obtenir le tableau de caractères de retour dans main fonction?

#include<stdio.h>
#include<string.h>
int main()
{
    int i=0,j=2;
    char s[]="String";
    char *test;

    test=substring(i,j,*s);   
    printf("%s",test);
    return 0;
}


char *substring(int i,int j,char *ch)
{
    int m,n,k=0; 
    char *ch1;
    ch1=(char*)malloc((j-i+1)*1);
    n=j-i+1;

    while(k<n)
    {   
        ch1[k]=ch[i];
        i++;k++;
    }   

    return (char *)ch1;
}

S'il vous plaît dites-moi ce que je fais mal?

source d'informationauteur sayan