Using a range based for loop with a C-style array - C++ Data Type

C++ examples for Data Type:Array

Description

Using a range based for loop with a C-style array

Demo Code

#include <cinttypes>
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    const int numberOfElements{ 5 };
    int32_t normalArray[numberOfElements]{ 10, 65, 3000, 2, 49 };

    for (auto&& number : normalArray)
    {//  ww  w. j  a v  a 2 s .c  om
        cout << number << endl;
    }

    return 0;
}

Result


Related Tutorials