Segmentation fault in DAG

46 Views Asked by At

How to Fix this Segmentation fault in, I have tried Some alternatives but still it's not working.

strcpy(temp->label,'\0');
strcpy(temp->target,'\0');
1

There are 1 best solutions below

1
On BEST ANSWER

this is not correct

strcpy(temp->label,'\0');

strcpy wants a pointer to a string, you mean

 strcpy(temp->label,"\0");

or even simpler

 strcpy(temp->label,"");

this assumes that temp->lable has memory assigned to it in some way

EDIT: this is the most efficient way

 temp->label[0] = '\0';