Answers for "for loop over array in c++"

C++
13

for loop with array c++

int v[] = {1,2,3,4,5};
for (int n : v)
  cout << n << endl;
//make sure to compile with -std=c++11
Posted by: Guest on August-14-2020
0

c++ loop through array

CustomType customArray[]{5,6,7,8,9};
for (auto index = 0; index < std::extent_v<decltype(customArray)>; ++ index) {
// do stuff
}
Posted by: Guest on January-21-2022

Browse Popular Code Answers by Language