I'm aware the C++11 way of doing this, but I'm told to use the "traditional" way.
Anyways here's the code:
#include <iostream>
#include <array>
#include <iomanip>
using namespace std;
int main()
{
int items[ 5 ] = {1, 2, 3, 4, 5};
cout << "items before modification: ";
for( unsigned int whatever = 0; whatever < sizeof(items); whatever++ )
{
cout << items[ whatever ] << " ";
}
}
Here is the output:
items before modification: 1 2 3 4 5 1 -1073949596 -1073949588 -1073949744 -1217175552 0 0 -1218570461 134514560 0 0 -1218570461 1 -1073949596 -1073949588
Where did I went wrong where I'm expecting this output:
items before modification: 1 2 3 4 5
?
Aucun commentaire:
Enregistrer un commentaire