Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help readin from file

Status
Not open for further replies.

sharktlp

Technical User
Nov 19, 2003
5
0
0
US
I have to read a few words from a file and save it into a tree so i can search. the file contains these words.



cat
dog
car
mother
nike
hat
last





this is what i have so far

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

void main()
{
long int i=0;



char ch;
char out[100];

ifstream iFile(&quot;c:/dictionary.txt&quot;);

if (! iFile)
{
cout << &quot;Error opening input file&quot; << endl;
exit(1);
}



while(iFile.get(ch))
{
switch (ch) {


case ' ':
i=i+5;
break;

case '\n':
i=i+5;
break;
break;
default:

out=ch;

cout<<out<<i;
i++;
break;
}

}








}


i want to read each word and store it in its own seperate string how can i do that thanks
 
I think that you want the C++ forum ... this is VB 5/6.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top