-
well with the fixed corrections im only getting one error at the return saying i cannot convert from an info_node* to int..
Code:
int build_list(struct info_node* pnode)
{
FILE* infile ;
struct info_node* link1 ;
struct info_node* top ;
int result ;
infile = fopen("p3purge_data.txt", "r") ;
link1 = (info_node *)malloc(sizeof(info_node) ) ;
fscanf( infile, "%s%s%d%f", link1->fname , link1->lname, &link1->rank, &link1->score ) ;
top = link1 ;
fclose(infile);
return(top) ;
}
-
That is true. You can't. So don't.
Code:
struct info_node * build_list(struct info_node* pnode)
-
so using that case how would i call the function
-
The same way... you would need casts for your current implementation. And casts be damned, your current implementation is just plain wrong.
-
so the call would be something similiar to:
Code:
result = build_list(top) ??
Code:
struct info_node * build_list(struct info_node* pnode)
{
FILE* infile ;
struct info_node* top;
int result = 0;
infile = fopen("p3purge_data.txt", "r") ;
pnode = (info_node *)malloc(sizeof(info_node) ) ;
fscanf( infile, "%s%s%d%f", pnode->fname , pnode->lname, &pnode->rank, &pnode->score ) ;
top = pnode ;
fclose(infile);
return(top) ;
}
-
Why do you want result to be an int? Why would it ever be an int anyway? You want a pointer to an object not an integer. You could cast, but again, why?
-
kk so i have it to build my list, quick question(if i do all the same things to build a separate list can i return two values under two different names(ie: return(top, top2)
-
You can call the function twice to build two different lists, yes. You can't return two different lists from the same function call.
-
but i could pass the two different infiles in..got it. but say i wanted to use string compare to remove copied names out of one list that are in the other..is there any special approach to that or can i just use string compare in main somehow remove nodes that are copied?