Function call to linked list

hello..i was wondering if anyone could take a look at my code which makes two linked lists from infiles. the lists work fine as i have tested printing them out i just need help to make a function that builds the link list instead of the way i have it now(i am not very good with functions). Any help would be much appreciated

I maybe added a grand total of a dozen lines to your existing code. But to be honest, you need to really look at some of your return values. Don't always just assume a file will open up. Don't always assume malloc() will give you a return value. Assume nothing about any area where errors can be introduced.

The getting the block of memory definitely belongs inside the function.

As to the scanning, that gets a little tricky. I would recommend passing in the values to be added to the list into the function, rather than reading it in. (This way your list can adapt to keyboard input, or even other file input.)

Lol. No hard feelings. I didn't do anything more than copy and paste your main() function into another function. But I ultimately added that mangle_name() function just to make things a little more automated. Perhaps that will be a keeper for your code.