Question: Could help me fix the error? my project is find the middle node in the linked list. output text file should sorted with ascending order

Could help me fix the error?

my project is find the middle node in the linked list. output text file should sorted with ascending order

please check my code below

#include #include # include #include #include using namespace std;

struct Node { int data; struct Node* next; }; void printMiddle(struct Node *head) { struct Node *slow_ptr = head; struct Node *fast_ptr = head; if (head!=NULL) { while (fast_ptr != NULL && fast_ptr->next != NULL) { fast_ptr = fast_ptr->next->next; slow_ptr = slow_ptr->next; } printf("The middle element is [%d] ", slow_ptr->data); } } void push(struct Node** head_ref, int new_data) { struct Node* new_node = (struct Node*) malloc(sizeof(struct Node)); new_node->data = new_data; new_node->next = (*head_ref); (*head_ref) = new_node; } void printList(struct Node *ptr) { while (ptr != NULL) { printf("%d->", ptr->data); ptr = ptr->next; } printf("NULL "); }

int main() { ofstream file_; file_.open("mytext.txt"); file_ <<"91"<<" "<<"322"<<" "<<"9"<<" "<<10 < file_ <<"77"<<" "<<"8"<<" "<<"999"<<" "<<12 < file_ <<"133"<<" "<<"14" < file_ <<"8"< file_ <<"538"<<" "<<"29"<<" "<<"91" < file_ <<"88" < file_ <<"702"<<" "<<"361" < file_ <<"637" < file_ <<"99" <

file_.close(); std::string line_; ifstream file_("mytext.txt"); if(file_.is_open()) { while(getline(file_, line_)) { std::cout< } file_.close(); } else std::cout<<"file is not open"<< ' '; std::cin.get(); 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!