for(auto const& value: a) {
/* std::cout << value; ... */
}
for (int i = 0; i < Vector.size(); i++)
{
type Element = Vector[i];
}
for(int i = 0; i < vec.size(); i++){
cout << vec[i] << endl;
}
for (const auto& i : vector)
{
// do something
}
for (auto & element : vector) {
element.doSomething ();
}
vector<int> vi;
...
for(int i : vi)
cout << "i = " << i << endl;
for(std::vector<T>::size_type i = 0; i != v.size(); i++) {
v[i].doSomething();
}
// Using a for loop with iterator
for(std::vector<int>::iterator it = std::begin(v); it != std::end(v); ++it) {
std::cout << *it << "
";
}
Code Example |
---|
Cpp :: copy array c++ |
Cpp :: adding elements to a vector c++ |
Cpp :: random number in a range c++ |
Cpp :: c++ char to uppercase |
Cpp :: how to read and parse a json file with rapidjson |
Cpp :: c++ for in |
Cpp :: c++ sleep |
Cpp :: c++ initialize array 1 to n |
Cpp :: tuple c++ |
Cpp :: how to put bitset into a string in c++ |
Cpp :: struct and array in c++ |
Cpp :: how to get size of char array in c++ |
Cpp :: int to string c++ |
Cpp :: max element in array c++ stl |
Cpp :: c++ max of array |
Cpp :: find primes in a range in c++ |
Cpp :: c++ factorial |
Cpp :: why we use iostream in C++ programming |
Cpp :: vector size for loop |
Cpp :: c++ get character from string |
Cpp :: continue c++ |
Cpp :: set clear c++ |
Cpp :: how to declare a 2d boolean vector in c++ |
Cpp :: string to upper c++ |
Cpp :: C++ break with for loop |
Cpp :: c++ average |
Cpp :: Header for INT_MIN |
Cpp :: check prime cpp gfg |
Cpp :: c++ add two char together |
Cpp :: error handling in c++ |