basic for loop in c++ for array reading code example
Example 1: c++ loop through array
string texts[] = {"Apple", "Banana", "Orange"};
for( unsigned int a = 0; a < sizeof(texts); a = a + 1 )
{
cout << "value of a: " << texts[a] << endl;
}
Example 2: 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