I have a problem with my program. Im making a simple codifying-prog with a dummy alfabeth, but when trying to access the char array it can't access the location, how come? I dont know if it has to do with the size_t type instead of int type?
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
static char * createAlfa(void);
char * codify(char *mess, char *alfa);
int
main(void)
{
    char *alfa=createAlfa();
    printf("write your mess to codify: \n");
    char mess[]="";
    scanf("%s", mess);
    char *code=codify(mess, alfa);
    printf("your codified message is: %s\n", code);
    return 0;
}
static char *
createAlfa(void)
{
    char *codealfa=malloc(sizeof(char)*27);
    srand((unsigned int)time(NULL));
    int i, ran;
    for(i=0; i<26; i++)
    {
        codealfa[i]='A'+i;
        if((ran=rand()%26)<i)
        {
            codealfa[i]=codealfa[ran];
            codealfa[ran]='A'+i;
        }
    }
    codealfa[26]=0;
    return codealfa;
}
char *
codify(char *mess, char *alfa)
{
    size_t len=strlen(mess);
    char *code=malloc(sizeof(char)*len);
    int i;
    for(i=0; i<len; i++)
    {
        int pos=(int)(toupper(mess[i])-'A');  //pos is behaving correctly, first loop is 
                                              //it is 15 when i write "potato"
        code[i]=alfa[pos];      //EXC_BAD_ACCESS, Could not access memory
    }
    code[i]=0;
    return code;
}
 
     
     
     
    