hello im having some trouble in my function call here.. what i am trying to accomplish is to build a linked list in a function and send the link back to main. Can anyone sort out my problem?(i think it might be syntax with how i am calling the function)
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 ;
} ;
int build_list(struct info_node*, int)
int main()
{
FILE* infile ;
FILE* infile2 ;
struct info_node* link1, * link2 ;
struct info_node* top, * top2 ;
struct info_node* move_pntr = NULL, * move_pntr2 = NULL ;
struct info_node* pre_pntr ;
struct info_node* current_pntr ;
int num = 0 ;
infile2 = fopen("p3data.txt", "r") ;
infile = fopen("p3purge_data.txt", "r") ;
build_list(&link1, &top) ;
fclose(infile);
fclose(infile2);
return (0) ;
} //end of func main()
int build_list(info_node * lk1, int tp)
{
int pre_pntr = NULL ;
int current_pntr = NULL ;
while( !feof(infile) )
{
lk1 = (info_node *)malloc(sizeof(info_node) ) ;
fscanf( infile, "%s%s%d%f", lk1->fname , lk1->lname, &lk1->rank, &lk1->score ) ;
lk1->next = NULL ;
pre_pntr = lk1 ;
current_pntr = lk1 ;
tp = lk1 ;
lk1->next = tp ;
tp = lk1 ;
}
return(*tp) ;
}