#include <iostream>
#include <vector>
using namespace std;
vector<int> myvector;
for (vector<int>::iterator it = myvector.begin();
it != myvector.end();
++it)
cout << ' ' << *it;
cout << '
';
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
}
vector<T>::iterator iteratorName;
for (auto & element : vector) {
element.doSomething ();
}
vector<int> vi;
...
for(int i : vi)
cout << "i = " << i << endl;
for(auto i = begin(vec); i != end(vec); i++){
cout << *i << endl;
}
}
for(std::vector<T>::size_type i = 0; i != v.size(); i++) {
v[i].doSomething();
}
vector<int>::iterator ptr;
for (ptr = ar.begin(); ptr < ar.end(); ptr++)
{
//do something at (*ptr)
}
vector<string> split ( const string& str ) // const-correct
{
vector<string> ret;
typedef string::const_iterator iter ;
iter i = str.begin() ;
// ...
return ret;
}
// 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 :: c++ how to get maximum value |
Cpp :: search in vector of pairs c++ |
Cpp :: converter c++ to c |
Cpp :: vector remove class |
Cpp :: palindrome no example |
Cpp :: short hand if else in c++ |
Cpp :: for statement in c++ |
Cpp :: inpout in Array c++ |
Cpp :: constructor overloading in c++ |
Cpp :: https://www.codegrepper.com |
Cpp :: declaring multiple variables in cpp |
Cpp :: char * to string c++ |
Cpp :: no match for ‘operator=’ (operand types are ‘std::basic_ostream’ and ‘int’) |
C :: c colourful output |
C :: what is meaning of product *= in c |
C :: print an array in c |
C :: c program hide console window |
C :: print boolean value in c |
C :: close file in c |
C :: reverse integer in c |
C :: print ascii value in c |
C :: c program |
C :: what is covert channel |
C :: to find greatest of 4 numbers in c |
C :: uuidv4 javascript |
C :: array value from user c |
C :: how to make sure input is integer c |
C :: #define arduino |
C :: c convert float to string |
C :: create array of strings in c from user input |