CPS 393 Lecture Notes - Lecture 9: Linked List, Gnu Debugger, While Loop

59 views5 pages

Document Summary

Searching through the linked list: eg: treename spruce\0 so it checks through at each node p is a variable inside the function checktree pass spruce\0 into the function. /* a function to check if a tree is in the list. #define nl 20 typedef struct tree { char tree_name [nl]; struct tree* next; }tree; int checktree (tree *p, char name[]){ // receive the address of the ll and array. // name is a pointer disguised as an array!!! // this is bc name contains an address int found = 0; while (p != null) > tree_name, name) == 0) // want to compare if spruce is equal to any of the trees found = 1; // if they match set found to 1 p = p -> next; return (found); int main(){ /* declaring variables to hold tree nodes */ tree tree1, tree2, tree3, tree4;

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents