<<split>>

very intersting tutorial , thank u for it but i have one problem , how can i compare a string1 from a file with string2 from another file??

  • create 2 objects of type 'ifstream'
  • open the two files
  • read in the desired stuff to a container of your choice (usually string objects or vectors)
  • compare the two strings
string word1, word2;
ifstream infile1, infile2;

infile1.open("doc1.txt");
infile2.open("doc2.txt");

word1 << infile1;
word2 << infile2;

if(word1 == word2)
    cout << "Same";

else
     cout << "Different";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.