I am trying to make all possible combinations of alphabets using a number. Input NUM given by user.
The combinatitions are created by splitting input numbers upto two digits. Input Obtained as char*
I am Using C. I am getting output as Segmenation fault (core dumped), guessing because of the warning.
substr is my own function.
sample input and output
input: 11112
output: 
AAAAB
AAAL
AAKB
AKAB
AKL
KAAB
KAL
KKB
My CODE
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char* substr(char* str,int l,int n)
{
    char* c;
    int len = n-l;
    while(l<n)
    {
        *c = *(str+l);
        l++;
        c++;
    }
    *c='\0';
    return c-len;
}
int printAlpha(char* str, char* word)
{
    char *sub;
    char* ch;
    int n = strlen(str);
    if(n == 0)
    {
        printf("%s",word);
    }
    else
    {
     sub = substr(str,0,1);
     int num = atoi(sub);
     str = substr(str,1,n);
     ch = 'A'+(num-1); 
     printAlpha(str, strcat(word, ch));
     sub = substr(str,0,2);
     num = atoi(sub);
     if(strlen(str)>=2 && num <= 26)
     {
         str = substr(str,2,n);
         ch = 'A'+(num-1);
         printAlpha( str, strcat(word, ch) );
     }
    }
    return 0;
}
int main()
{
    char* str;
    char* word = '\0';
    scanf("%s",str);
    printAlpha(str,word);
    return 0;
}
thanks in advance.
 
     
    