I am having a problem with understanding the concept of dynamic memory allocation, I have some code that is encountering a segfault perhaps some one may have some insight?
 #include <stdio.h>
 #include <stdlib.h>
typedef struct tName
{
   char **stringA;
   int capacity;
} tName;
tName *createTName(int length);
tName *destroyTName(tName *l);
int main(void) {
    tName *ll = createTName(10);
}
tName *createTName(int length) {
    tName *temp;
    int i;
    temp->capacity = length;
    temp->stringA= (char**) malloc(sizeof(char*) * length);
    for(i=0;i<length;i++)
       temp->stringA[i] = (char*) malloc(sizeof(char)*50);
    return temp;
}
When I call run this program I get a segfault, can anyone assist me please?
 
    