Skip to content

Instantly share code, notes, and snippets.

@LizardLeliel
Created October 28, 2014 22:43
Show Gist options
  • Save LizardLeliel/83fc80b37bfea9b37a35 to your computer and use it in GitHub Desktop.
Save LizardLeliel/83fc80b37bfea9b37a35 to your computer and use it in GitHub Desktop.
Linked List demonstration
#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