+ 2

logic of arrays and loops ?

so i learned arrays and made this int x; int usk[] = { 0, 1, 2, 3}; for (x = 0 ; x < 8 ; x++) { cout << usk[x] << endl; } i know its wrong but whats the logic behind the printed numbers (0 1 2 3 7601948 596681 1 8931488 ? does it matter which compiler you are using?

1st Mar 2017, 6:55 PM
Boson Higgs
Boson Higgs - avatar
2 Antworten
+ 14
Just undefined garbage values stored within the system. Compilers do not check whether or not your array iterations are out of bound.
1st Mar 2017, 2:19 PM
Hatsy Rei
Hatsy Rei - avatar
0
All I know is that the only thing a compiler does is run your code it shouldn't matter what one you are using it should output the same thing as anything else
13th Aug 2021, 3:39 AM
kyle
kyle - avatar