NEED HELP?? pls....

how to put a file from filestream to add into the linkedlist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 ofstream kim;
string filename;
cout<<"Enter Your Name:"<<endl;
cin>>filename;
kim.open(filename.c_str());
// after this one.. how can i put it in linked list??
if (!kim)
	{
		kim << "File could not be opened." << endl;
		exit(1);
	}
//////////////////////////////////////////////////////
// then, how can i determine or to call my file into this function
void insertFrontNode(void)
		{
			node*head2=new node;
			cout<<"Enter a numeric item:";
			cin>>head2->item;
			if(head==NULL)
			{
				head2->next=NULL;
			}
			else
			{
				head2->next=head;
			}
			head=head2;

			return;
		}
/////////////////////////////////
//after that, how i will see the filename by using this function
void Traverse(void){
			node*temp=new node;
			temp=head;
			while(temp!=NULL)
			{
				cout<<"\t\t|"<<temp->item<<"|"<<endl;
				temp=temp->next;
			}
			return;
		}
Do you really intend to store the file inside of your linked list? Or do you intend to store the contents of the file inside the linked list?
actually the contents of the file into linked list.. because for example..

I will be using a Traverse or search
KIM
JAMES
RAMOS

this is will the linked list..
but when I enter 1 it is KIM.
So it will open the contents of the file
For reading the file look at
http://www.cplusplus.com/doc/tutorial/files/

You need to think about how to store your data in your list
You should use strings to store the names in your file.
Take a look at the link below and use string where he uses int;

Try following this (simple list)
https://www.youtube.com/watch?v=U-MfAoL6qjM

hope that helps.
Thanks... But the url that you give me is i've already know..

I want to call may files to add it.. and to search for it.. in linked list..
Topic archived. No new replies allowed.