Cpp loops

From wikinotes

loops

for loop

     // init vars //   // exit-condition //   // operation //
for (  n=0, i=100 ;     n!=i ;                 ++n, --i )
{
   // whatever here...
}

for each loop

arrays

int items[] = {11, 14, 25};
std::for_each(int item: items)
{
...
}

vectors

vector<int> items = {11, 14, 25};
std::for_each(items.begin(), items.end(), [](Attack * attack)
{
...
}

while loops

while (x < 0) {
	x++;
}
do {
	x++;
} while (x < 0)

range loops

string my_string = "hello";

    //define type//  //variable to iterate through//
for (auto chr      :    my_string)
	cout << chr;

//>>> [h][e][l][l][o]