- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Input Iterators in C++
In this tutorial, we will be discussing a program to understand input iterators in C++.
Input iterators are one of the five iterators in STL being the weakest and simplest of all. They are mostly used in serial input operations where each value is read one and then the iterator moves to the next one.
Example
#include <iostream> #include <vector> using namespace std; int main(){ vector<int> v1 = { 1, 2, 3, 4, 5 }; //declaring iterator vector<int>::iterator i1; for (i1 = v1.begin(); i1 != v1.end(); ++i1) { //looping over elements via iterator cout << (*i1) << " "; } return 0; }
Output
1 2 3 4 5
Advertisements