C++ STL istreambuf_iterator::equal() program example
Compiler: Visual C++ Express Edition 2005
Compiled on Platform: Windows XP Pro SP2
Header file: Standard
Additional project setting: Set project to be compiled as C++
Project -> your_project_name Properties -> Configuration Properties -> C/C++ -> Advanced -> Compiled As: Compiled as C++ Code (/TP)
Other info: none
To do: Using the C++ istreambuf_iterator::equal() to test for equivalence between two input stream buffer iterators in C++ programming
To show: How to use the C++ istreambuf_iterator, equal() to test for equivalence between two input stream buffer iterators in C++ programming
// C++ STL istreambuf_iterator, equal()
#include <iterator>
#include <iostream>
using namespace std;
int main(void)
{
cout<<"\nOperation: bol = readchinpt1.equal(readchinpt2)"<<endl;
cout<<"Enter a line of text then an Enter key to insert into the output:"<<endl<<endl;
// reading input
istreambuf_iterator<char> readchinpt1(cin);
istreambuf_iterator<char> readchinpt2(cin);
// test
bool bol = readchinpt1.equal(readchinpt2);
if(bol)
cout<<"The iterators are equal."<<endl;
else
cout<<"The iterators are not equal."<<endl;
return 0;
}
Output examples:
Operation: bol = readchinpt1.equal(readchinpt2)
Enter a line of text then an Enter key to insert into the output:
This is a line of text
The iterators are equal.
Press any key to continue . . .