Skip to content

Instantly share code, notes, and snippets.

@raju249
Created July 21, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raju249/e982c977ef7029cfef7d to your computer and use it in GitHub Desktop.
Save raju249/e982c977ef7029cfef7d to your computer and use it in GitHub Desktop.
/**
* Searches for a number in list.
*/
void search(void)
{
// prompt user for number
printf("Number to search for: ");
int n = GetInt();
// get list's first node
node* ptr = first;
// search for number
while (ptr != NULL)
{
if (ptr->n == n)
{
printf("\nFound %i!\n", n);
sleep(1);
break;
}
ptr = ptr->next;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment