HELP! simple dictionary..cant search..

guyss need help for search....there is no content when i search word in the dictionary.txt....this is my example of dictionary.txt...in the add case it is working,,only in search case...

--------------
dictionary.txt
--------------
mwet-asd.
test-test.
apple-prutas.
beryy-berry.
house-house.
--------------


#include <iostream>
#include <fstream>
#include <string>
#include <conio.h>
using namespace std;
int counter=0;
char op;

int main () {
ifstream write("dictionary.txt", ios::in);
ofstream read("dictionary.txt", ios::app);
string word,meaning;

if(!write){
cout<<"file not found!!";
system ("pause");
return 0;
}
cout<<"\t*DICTIONARY*\n";
cout<<"============================";
cout<<"\n\n[a] Add word";
cout<<"\n[s] Search word";
cout<<"\n\n============================";
cout<<"\nEnter operation:";
cin>>op;
cout<<"\n============================\n";
switch (op){ case 'a':

{cout<<"\nEnter word:\n";
cin>>word;
cout<<"\nEnter meaning:\n";
cin>>meaning;

read<<"\n"<<word<<"-"<<meaning<<".";
break;}

case 's':
{ string aword,ameaning;
string add;
cout<<"Enter word to search:";
cin>>add;
if (add==aword){
while (getline(write,aword)) {
aword = add.substr(0, add.find("-"));
add = add.substr(aword.length()+1,aword.length());
ameaning = add.substr(0, add.find("."));}}


cout<<"====================================";
cout<<"\nword:"<<aword<<add<<"\n";
cout<<"\nmeaning:"<<ameaning<<"\n";
cout<<"====================================\n";
system("pause");
getch ();
}
}
}
Last edited on
Topic archived. No new replies allowed.