I am referring a book programming in c by Kochan and i am not getting few things on a particular code.
First thing is the (struct entry *) 0 expression in while loop and other one is return (struct entry *) 0;Code:#include <stdio.h> struct entry { int value; struct entry *next; }; struct entry *findEntry (struct entry *listPtr, int match) { while ( listPtr != (struct entry *) 0 ) if ( listPtr->value == match ) return (listPtr); else listPtr = listPtr->next; return (struct entry *) 0; } int main (void) { struct entry *findEntry (struct entry *listPtr, int match); struct entry n1, n2, n3; struct entry *listPtr, *listStart = &n1; int search; n1.value = 100; n1.next = &n2; n2.value = 200; n2.next = &n3; n3.value = 300; n3.next = 0; printf ("Enter value to locate: "); scanf ("%i", &search); listPtr = findEntry (listStart, search); if ( listPtr != (struct entry *) 0 ) printf ("Found %i.\n", listPtr->value); else printf ("Not found.\n"); return 0; }
Also does the struct entry *findEntry and struct entry * findEntry(with space asterik and function name) makes any difference



6Likes
LinkBack URL
About LinkBacks




but after reading your post to the end i grasped what you tried. Thanks a tone.