What happens after the end of character array in c? -
this question has answer here:
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
Post a Comment