Hello so i'm something new to linked lists and data structrs generally so i want to creat two functions one initiallise the doubly linked list and the other one print it but when i compile it it doesnt print anything where did i miss exactly (i heard that i should use the debugger but i didnt understand how to use it on Dev c++ IDE)
#include <iostream>
#include <stdlib.h>
using namespace std;
struct Node
{ int data;
Node *next;
Node *previous;
};
Node *head,*end;
Node* insertion()
{
Node *first_node =new Node;
if (head==NULL || first_node==NULL)
exit(EXIT_FAILURE);
first_node->data=10;
first_node->previous=NULL;
first_node->next=NULL;
head=first_node;
end=first_node;
return head;
}
void affiche()
{
Node *current;
current=head;
if(head==NULL)
exit(EXIT_FAILURE);
while(current->next!=NULL)
{
cout<<current->data <<" ";
current=current->next;
}
}
int main()
{
Node *MyList=insertion();
affiche();
return 0;
}
Aucun commentaire:
Enregistrer un commentaire