core dumped when copying a string to first element of the pair

29 Views Asked by At

I have a list of pairs: list<pair<string, list>> and i also have a string A and an iterator for the list named ti When I try to copy A to (*ti).first by writing a code (*ti).first += A or (*ti).first = A or strcpy((*ti).first, A) I always get the error "core dumped". I have also tried to allocate the memory for (*ti).first by using (*ti).first = (char)malloc(sizeof(A)) but nothing helped

I tried memory allocation for the first element of the pair, I tried copying the string in different ways such as strcat, strcpy, +=, =.

0

There are 0 best solutions below