What happens after the end of character array in c? -


what's stored after end of character array? assuming there random garbage did not print after end while looping 10 times.

char a[] = "pencil"; int i;  (i = 0; < 10; i++) {     printf("%c", a[i]); } 

so character array has size of 7. , loop looped until 10th position 3 more values looped through. did not print or error. what's going on here?

accessing beyond end of array in c undefined behavior. program continue running unchanged or crash horrifically depending on stored past end of array. compiler makes no guarantees stored there - useless memory or critical program.


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -