+ 1

please help me to correct this code

my loop is not working please help. https://code.sololearn.com/cVUqBikL9emH

17th Feb 2022, 12:35 PM
Aman Prasad
Aman Prasad - avatar
1 Answer
+ 1
Nice code! I'm getting segmentation fault, is there a bracket you forgot to close? Is recursion the best way to loop your program? Doesn't that hold each iteration of the function in memory until it reaches the final run? {edit: I got it to run but I'm not sure this is how it should be ... I added an equals to make the if a comparison instead of an assignment, and I enclosed the recursive call to be inside the else statement} if (list->data==-999) { list->link=NULL; } else{ list->link = (struct node*)malloc(sizeof(struct node)); create(list->link); } return;
17th Feb 2022, 7:59 PM
HungryTradie
HungryTradie - avatar