Skip to content

Instantly share code, notes, and snippets.

@ngerakines
Created September 30, 2015 20:55
Show Gist options
  • Save ngerakines/f1520d2d9b4f80a036b3 to your computer and use it in GitHub Desktop.
Save ngerakines/f1520d2d9b4f80a036b3 to your computer and use it in GitHub Desktop.
#include <iostream>
struct Node
{
int data;
struct Node *next;
};
void Print(Node *head)
{
std::cout << head->data << std::endl;
while (head->next != NULL) {
head = head->next;
std::cout << head->data << std::endl;
}
}
// g++ main.cpp && ./a.out
int main()
{
std::cout << "Hello world!" << std::endl;
Node a;
a.data = 1;
Node b;
b.data = 2;
b.next = NULL;
a.next = &b;
Print(&a);
Print(&b);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment