I'm trying to implement a linked list (At the end of node) on code::blocks 17.12 but there isn't showing any output. This Code is showing me a black output screen with a following message in my logs:
-------------- Build: Debug in Delete duplicate-value in Linked List (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -Wall -fexceptions -g -c "C:\Users\hp\Desktop\CPP Programming\Delete duplicate-value in Linked List\main.cpp" -o obj\Debug\main.o mingw32-g++.exe -o "bin\Debug\Delete duplicate-value in Linked List.exe" obj\Debug\main.o
Output file is bin\Debug\Delete duplicate-value in Linked List.exe with size 1.51 MB Process terminated with status 0 (0 minute(s), 1 second(s)) 0 error(s), 0 warning(s) (0 minute(s), 1 second(s))-------------- Run: Debug in Delete duplicate-value in Linked List (compiler: GNU GCC Compiler)---------------
Checking for existence: C:\Users\hp\Desktop\CPP Programming\Delete duplicate-value in Linked List\bin\Debug\Delete duplicate-value in Linked List.exe Executing: "C:\Program Files (x86)\CodeBlocks/cb_console_runner.exe" "C:\Users\hp\Desktop\CPP Programming\Delete duplicate-value in Linked List\bin\Debug\Delete duplicate-value in Linked List.exe" (in C:\Users\hp\Desktop\CPP Programming\Delete duplicate-value in Linked List.) Process terminated with status -1073741510 (0 minute(s), 10 second(s))
#include <iostream>
#include<stdlib.h>
#include<bits/stdc++.h>
#include<conio.h>
using namespace std;
struct Node
{
int data;
Node *next;
};
void pushinorder(struct Node** head, int new_data)
{
struct Node* new_node = (struct Node*)malloc(sizeof(struct Node));
struct Node *temp = *head;
new_node->data = new_data;
new_node->next = NULL;
if(*head==NULL)
{
*head = new_node;
return;
}
while(temp->next!=NULL)
{
temp = temp->next;
}
temp->next = new_node;
return;
}
void PrintList(struct Node* head)
{
struct Node *temp = head;
while(temp!=NULL)
{
cout<<temp->data<<" ";
temp=temp->next;
}
}
int main()
{
struct Node *head = (struct Node*)malloc(sizeof(struct Node));
pushinorder(&head,1);
pushinorder(&head,1);
pushinorder(&head,1);
pushinorder(&head,2);
pushinorder(&head,2);
pushinorder(&head,3);
pushinorder(&head,3);
pushinorder(&head,3);
pushinorder(&head,3);
pushinorder(&head,4);
PrintList(head);
getch();
return 0;