Today I Learned
C++ range-for-statement
# include
<iostream>
</iostream>
using namespace std;
int main(){
int v[] = {1,3,5,7};
for( auto x:v)
{
cout << x << endl;
}
}
What this does is to copy each element of array v into x and print it. For efficiency, we could use instead pointers.
for(auto& x : v) { cout << &x << endl; }