Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- static const int max_word_count = 50;
- static const int word_length = 30;
- int read_in(string e[][word_length], string f[][word_length]);
- void sort_words(string e[][word_length], string f[][word_length], const int used);
- void search_words(const string e[][word_length], const string f[][word_length], const int used);
- void write_out(const string e[][word_length], const string f[][word_length], const int used);
- int main()
- {
- string englishWords[max_word_count][word_length];
- string frenchWords[max_word_count][word_length];
- int num;
- num = read_in(englishWords, frenchWords);
- sort_words(englishWords, frenchWords, num);
- search_words(englishWords, frenchWords, num);
- write_out(englishWords, frenchWords, num);
- return(0);
- }
- int read_in(string e[][word_length], string f[][word_length])
- {
- ifstream infile;
- infile.open("dict.txt");
- if(!infile)
- {
- cout<<"Error opening output file"<<endl;
- return -1;
- }
- int count = 0;
- while(count<max_word_count && infile >> e[count][word_length])
- {
- while(cin.peek()==' ')
- cin.get();
- getline(cin, f[count++][word_length]);
- }
- infile.close();
- //what do mean by return number used?
- } //have warning here says "Control reaches end of non-void function"
- void sort_words(string e[][word_length], string f[][word_length], const int used)
- {
- for(int i = 0; i < used; i++)
- {
- for(int j = (i + 1); j < used; j++)
- {
- if(e[j][word_length] < e[i][word_length])
- {
- string temp = e[j][word_length];
- e[j][word_length] = e[i][word_length];
- e[i][word_length] = temp;
- temp = f[j][word_length];
- f[j][word_length] = f[i][word_length];
- f[i][word_length] = temp;
- }
- }
- }
- }
- void search_words(const string e[][word_length], const string f[][word_length], const int used)
- {
- cout<<"Enter the English word you are searching for: ";
- //getline(cin, input); // have an error here
- cout<<"You entered: ";
- //not sure how to do the input properly
- //i would like to have this part clarified more
- }
- void write_out(const string e[][word_length], const string f[][word_length], const int used)
- {
- //and i don't get what exactly to do here
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement