say for a each line in the text file there are several words. I want to read each word, separated by space. how do i do that? how do i get each word in the line? each line is treated like a linked list and i want to store it in an array. how do i do that?.
for example
the text is
jeffrey jake john
charlie emilio martin
drew lucy cameron
i want jeffrey jake and john to be a linked list. charlie emilio martin, another. each line is a linked list
then i would store these linked list to an array.
but before i can do that. i must know how to read each word in a line.
please help...
thanks
How do I read a text file in C? make an array of linked lists?
Use fgets to store each line in a character buffer. Now use strtok to find the names separated by spaces. And linked list logic: well you can google that.
If you are having trouble finding information, look at http://cppreference.com/index.html or any C reference for that matter. For example, typing “man fgets” in google will get you useful information.
I assume you can look up on Google or your books how to create a linked list.
No comments:
Post a Comment