I initialize a pointer to string type and allocate some memory with malloc function. My problem is when i try to use one of the string pointed by this pointer, i get segmentation fault.
string anyString = "anyWords";
string *pointerToString;
pointerToString = (string *) malloc(sizeof(string) * 5);
pointerToString[i] = anyString; // this line causes segmentation fault
Thanks in advance for any help.