i have a problem with the allocation of a dynamic struct array. The struct is composed of a char* field, that is another dynamic array of char. After i allocate all arrays, windows block the program when i try to modifty a struct content. Code:
 typedef struct
 {
    char *cod;
 }code;
void create_cod(code *singleCode,int codeLength);
void create_codes(code *codes, int codesNumber, int codeLength);
int main()
{
  int codesNumber=4, codeLength=10;
  code *codes;
  create_codes(codes, codesNumber, codeLength);
  codes->cod = "abcd"; /*Windows block the program here*/
}
void create_cod(code *singleCode,int codeLength)
{
    singleCode->cod = (char*)malloc(codeLength*sizeof(char));
    return;
}
void create_codes(code *codes, int codesNumber, int codeLength)
{
    codes= (code*)malloc(codesNumber*sizeof(code));
    int i=0;
    while(i<codesNumber)
    {
        create_cod(codes+i,codeLength);
        i++;
    }
    return;
}