- read into temporary memory
- if successful, allocate a node, copy the data and append to the list.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
LIST *list = NULL;
while ( fread( &temp, sizeof temp, 1, fp ) == 1 ) {
LIST *node = makeNewNode( &temp ); // allocate and copy
list = append( list, node ); // append
}
Where is the junk node?
If the file is empty, then the list at the end is NULL (an empty list).
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
> p = A;
It seems you start off with a junk node to begin with.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953