I'm rather new to the C programming language and I'm very stuck. Whenever I try to assign a value to dynamically allocated string, I end up with a Segmentation Fault. Could someone help me by explaining why this happens. Following is a bit of my code that I think should provide enough information to help.
typedef char * Word;
typedef struct Panvowels
{
int num;
Word firstFive[5];
int firstFiveSize;
Word shortest, longest;
} PANVOWELS;
PANVOWELS panvowel = {0, (Word)malloc(5 * WORDSIZE), 0,
(Word)malloc(WORDSIZE), (Word)malloc(WORDSIZE)};
panvowel.shortest = "";
panvowel.longest = "";
panvowel.shortest[0] = 'a';