Solved programming problem

How to Create a linked List and Save Value in C++.

Source code

#include<iostream>

#include<string>

using namespace std;

struct list ///create a  structure for linked list

{

    int value;

    struct node *next;

};

typedef struct list Node; ///create a Node Type structure Variable

int main()

{

    Node *a;  ///node type variable

    a = new Node(); ///create space for new node

    a->value = 10; ///save value

    a->next = NULL; /// save address as null

    cout << "Data: " << a->value <<"";

    cout << "Address: " << a->next << "";

    return 0;

}

Output

Data: 10
Address: 0

Join the discussion

Add your comment