Why is undefined behaviour allowed in C

前端 未结 3 1006
忘掉有多难
忘掉有多难 2020-12-11 17:40

I have been messing around trying to learn C lately. Coming from Java, it surprised me that you can perform certain operations declared as \"undefined\".

This just

3条回答
  •  伪装坚强ぢ
    2020-12-11 18:10

    Java has a run time environment to take care of you. That's why an exception is thrown when going out of bounds - it's something that can't be figured out at compile time.

    There is run time bounds checking in C++ when using the at() method for a vector. It's what distinguishes at() from the []operator

提交回复
热议问题