Output of a C string program

半腔热情 提交于 2019-11-28 14:11:10

You are writing/reading outside of the bounds of the array, this is simply undefined behavior you can not make any predictions about what the program will do.

Accessing out of bound of an array is undefined behaviour. Just an example same code's output on my system is abcd(e▒x $($

string of length 8 is because of lack of NULL terminator and character ( between $ is garbage value of s[4].

  1. It isn't necessary for a runtime error to occur. C does no bound checking.
  2. There are many characters defined in C. Like the sound beep \a if I remebember correct so it isn't necessary that something is actually printed on the screen. It might have been a sound that you never heard.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!