c - printf unexplained behavior -
Recently I started learning C by myself, so this is a little new question It is possible. I have compiled the following commands:
#include & lt; Stdio.h & gt; Int main () {int arr [5] = {0}; Int arr2 [5] = {0}; Printf ("% d \ n", arrival [5]); // output here: 2130567168 printf ("% d \ n", AR2 [5]); // output here: 0 return 0; }
Can anyone explain the reason for a different output?
You are assessing the data that is outside the declared range of your index's index range, Declared as arr [5]
, goes from 0 ... 4, but you want to reach AR [5], which is neither defined nor allocated In this way you get random answers based on the value of memory "cell", which you want to use, in this case 0 and the second number.
Comments
Post a Comment