Created
September 30, 2015 20:55
-
-
Save ngerakines/f1520d2d9b4f80a036b3 to your computer and use it in GitHub Desktop.
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> | |
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