Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

c++ linked list

#include<bits/stdc++.h>
using namespace std;
struct Node
{
    Node *next;
    int data;
};
void print(Node *n)
{
    while(n!=NULL)
    {
        cout<<n->data<<" ";
        n=n->next;
    }
}
int main()
{
    Node* head,*second,*third = NULL;


    head=new Node();
    second=new Node();
    third=new Node();

//First Node
    head->data=1;
    head->next=second;

//Second Node
    second->data=2;
    second->next=third;

//Third Node
    third->data=3;
    third->next=NULL;
    print(head);
//@rahulsharmaah
}
 
PREVIOUS NEXT
Tagged: #linked #list
ADD COMMENT
Topic
Name
6+4 =