-
JIT Debugger Error Help
Here is my error.. any clues?
http://i20.photobucket.com/albums/b2...Untitled-1.jpg
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
struct info_node
{
char fname[20] ;
char lname[20] ;
int rank ;
float score ;
struct info_node * next ;
} ;
struct info_node * build_list(struct info_node*);
int main()
{
struct info_node* link1 ;
struct info_node* top = NULL ;
struct info_node* node ;
link1 = (info_node *)malloc(sizeof(info_node) ) ;
link1 = build_list(top) ;
printf( "%15s %15s %4d %5.2f \n", link1->fname , link1->lname, link1->rank, link1->score ) ;
return (0) ;
} //end of func main()
struct info_node * build_list(struct info_node* pnode)
{
FILE* infile ;
struct info_node* top = NULL;
struct info_node* pre_pntr = NULL;
struct info_node* current_pntr = NULL ;
infile = fopen("p3purge_data.txt", "r") ;
while( !feof(infile) )
{
if( top == NULL )
{
pnode = (info_node *)malloc(sizeof(info_node) ) ;
fscanf( infile, "%s%s%d%f", pnode->fname , pnode->lname, &pnode->rank, &pnode->score ) ;
pnode->next = NULL ;
top = pnode ;
current_pntr = top ;
}
else
{
pnode = (info_node *)malloc(sizeof(info_node) ) ;
fscanf( infile, "%s%s%d%f", pnode->fname , pnode->lname, &pnode->rank, &pnode->score ) ;
pre_pntr = current_pntr ;
current_pntr = current_pntr->next ;
pnode->next = top ;
top = pnode ;
}
}//end of !feof
fclose(infile);
return(top) ;
}
-
And so ... why didn't you actually use the debugger, instead of taking a screenshot of the system asking you whether you wanted to use the debugger?
-
i then get an error on line 44 saying stream != NULL
-
You don't have stream anywhere in your code. And which one is line 44?
-
nvm i got that fixed but i must have an error in my building of the list because when i return top and print the list only the last thing in the infile prints.
-
You build your list "backwards" (the last thing is at the top, the first thing is all the way at the end). And since you only print one thing, that's all you see.