Horje
for loop with array c++ Code Example
lopping over an array c++
for (int i = 0; i < arr.size(); ++i){
//use if we explicitly need the value of i
cout << i << ":\t" << arr[i] << endl;
}
for (int element : arr){
//modifying element will not affect the array
cout << element << endl;
}
for (int &element : arr){
//modifying element will affect the array
cout << element << endl;
}
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
C++, for-loop over an array array
/*sizeof(array_scores) is a pointer to array_scores[], 
and has to be divided by each first-object[0]*/
for(int a = 0; a < sizeof(array_scores)/sizeof(array_scores[0]); a = a + 1 ){
	cout << "for loop, a = " << array_scores[a] << " at position " << a << "\n";
}
//https://stackoverflow.com/questions/20234898/correct-way-of-looping-through-c-arrays




Cpp

Related
check uppercase c++ Code Example check uppercase c++ Code Example
c++ find element in vector Code Example c++ find element in vector Code Example
string to int in c++ Code Example string to int in c++ Code Example
swap values in array c++ Code Example swap values in array c++ Code Example
roscpp publish int32 Code Example roscpp publish int32 Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9