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) ;
}