Skip to content

Instantly share code, notes, and snippets.

@raju249
Created July 21, 2015 13:55
Show Gist options
  • Select an option

  • Save raju249/e982c977ef7029cfef7d to your computer and use it in GitHub Desktop.

Select an option

Save raju249/e982c977ef7029cfef7d to your computer and use it in GitHub Desktop.

Revisions

  1. raju249 created this gist Jul 21, 2015.
    24 changes: 24 additions & 0 deletions search.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    /**
    * 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;
    }
    }