Hello friends,
I am working on my class project, In which I have to read a text file with character separated by integer. Following is the format of the file:
I 23
I 67
I 89
D 23
F 89
I 62
I-Insert D-Delete and F-Find
After reading the text file, I need to perform the operations on binary search tree as directed.
I can write the program for insertion, deletion and find. The only problem I am facing here is how to get this data from file and check weather it is 'I', 'D' or 'F' and then perform the operation accordingly.
Could anybody help me please.
Following is the code I wrote for reading the data from file.
string s;
ifstream myfile("xyz.txt");
if(myfile.is_open()){
while(getline(myfile,s))
{
cout<<s<<endl;
}
myfile.close();
}
else cout<<"Unable to open file";
return 0;
}