Tuesday, December 16, 2014

Linked List Creation in C

Below is an example of how to implement a Linked List function using C. Note that the example below does not include a main function or preprocessor imperatives.
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;
}
view raw linked-list.c hosted with ❤ by GitHub

No comments:

Post a Comment