Click to See Complete Forum and Search --> : Linked Lists


April 19th, 1999, 11:43 PM
How would I read data from a file into a linked list while keeping it in the same order?

Samar Aarkotti
April 20th, 1999, 09:14 AM
I guess you have to get the file data using the string tokens one by one and store that in the LinkedList...
that would be in the same order... if you want the code let me know ... ;-)

here is the sample algorithm

Open the File...provided the data in the file would be like ... say
samar samar samar samar samar samar samar ( with space as delimiter or any other key)
then
call GetLine() and store it in the buffer,
using tokens like

char* token ;

token = strtok(buffer," "); // you can get each word saperately....

the push that token in the strcpy(Link->data, token);

i guess this is it....
if you want full fledge code then let me know ..... ;-)