Question: I'm getting errors in this code , can someone help . c programming language. let me know what the errors are . #include #include struct

I'm getting errors in this code , can someone help . c programming language. let me know what the errors are .

#include

#include

struct Node { int data; struct Node* next; };

void MoveNode(struct Node** destReference, struct Node** sourceReference);

// merges 2 sorted lists struct Node* Merge(struct Node* one, struct Node* two) { struct Node temp;

struct Node* start = &temp;

temp.next = NULL; while (1) { if (one == NULL) { start->next = two; break; } else if (two == NULL) { start->next = one; break; } if (one->data <= two->data) MoveNode(&(start->next), &one); else MoveNode(&(start->next), &two);

start = start->next; } return(temp.next); }

// moves the node from one place to the other void MoveNode(struct Node** destReference, struct Node** sourceReference) { struct Node* newNode = *sourceReference;

*sourceReference = newNode->next;

newNode->next = *destReference;

*destReference = newNode; }

// pushes the data into an array of ints void push(struct Node** head, int newData) { struct Node* newNode = (struct Node*) malloc(sizeof(struct Node));

newNode->data = newData;

newNode->next = (*head);

(*head) = newNode; }

void printList(struct Node* node) { while (node != NULL) { printf("%d ", node->data); node = node->next; } }

int main() { struct Node* result = NULL; struct Node* one = NULL; struct Node* two = NULL;

printf("this is going to get 4 numbers into 2 arrays then combine them and print the results ");

for (unsigned int i = 0; i < 4; i++) { int number; printf("add the %d number into the first array", i + 1); scanf_s("%d", &number); push(&one, number); }

for (unsigned int i = 0; i < 4; i++) { int number; printf("add the %d number into the second array", i + 1); scanf_r("%d", &number); push(&two, number); }

result = Merge(one, two);

printf("The result is: "); printList(result);

return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!