Hi,
I've got a serious problem. I'm supposed to compare two lists with eachother and it should output wich words can be found in both lists.
I've come up with abit how to do this, but im stuck! I'm thinking that you first count the number of letters in the first word, then compare it to the other word in the other list, here is a problem; how do i compare the first word in list #1 to the second word in list #2.
The lists;
List1;
Apple
Saussage
Dingle
List2;
Claw
Banana
Saussage
How can i make this simple and nice? Im really stuck.
Here is what i got now;
Wich really is NOTHING with what i need to do. I dont want anyone to do this for me, but i need a push in the right direction, how to get started and maybe a hint to how-to.Code:#include <cstdlib> #include <iostream> #include <fstream> #include <string> using namespace std; int counterone[250], countertwo[250], count, counttwo; char list_a[250], list_b[250]; int main(int argc, char *argv[]) { ifstream list1 ("lista1.txt"); ifstream list2 ("lista2.txt"); list1>>list_a; list2>>list_b; if (list1.is_open()) { cout<<"File 'list1' is open.\n"; cin.get(); } else { cout<<"File 'list1' could not be opened.\n"; cin.get(); return 0; } if (list2.is_open()) { cout<<"File 'list2' is open.\n"; cin.get(); } else { cout<<"File 'list2' could not be opened.\n"; cin.get(); return 0; } cout<<list_a; cin.get(); return 0; }
Thanks alot.