Created
October 28, 2014 22:43
-
-
Save LizardLeliel/83fc80b37bfea9b37a35 to your computer and use it in GitHub Desktop.
Linked List demonstration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
// Node Structure | |
struct Node { | |
int data; | |
Node *next; | |
}; | |
// Declaring (and defining) nodes | |
Node A = {423, NULL}; | |
Node B = {1991, &A}; | |
Node C = {2004, &B}; | |
// Linked List declaration | |
Node* linkedList = &C; | |
// Data output | |
while (linkedList != NULL) { | |
cout << (linkedList->data) << ' '; | |
linkedList = linkedList->next; | |
} | |
cout << endl; | |
cin.ignore(); | |
return 0; | |
} | |
//Output: 2004, 1991, 423 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment