Run ❯
Get your
own
website
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
#include
#include
using namespace std; int main() { string cars[3] = {"Volvo", "BMW", "Ford"}; // An array with 3 elements // Trying to add another element (a fourth element) to the cars array will result in an error cars[3] = "Mazda"; for (string car : cars) { cout << car << "\n"; } return 0; }
main.cpp:9:3: warning: array index 3 is past the end of the array (which contains 3 elements) [-Warray-bounds]
cars[3] = "Mazda";
^