Created
December 16, 2014 22:01
-
-
Save jwieder/f80ed669ecf85baed275 to your computer and use it in GitHub Desktop.
Example of linked list creation in C. Note this is merely a struct and function, and does not include a main function or preprocessor imperatives. Used in Harvard's CS50 class.
This file contains hidden or 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
typedef struct node | |
{ | |
int n; | |
struct node *next; | |
} | |
node; | |
bool search(int n, node* list) | |
{ | |
node* ptr = list; | |
while (ptr != NULL) | |
{ | |
if (ptr->n == n) | |
{ | |
return true; | |
} | |
ptr = ptr->next; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment