The terminating NULL in an array in C

前端 未结 9 1023
走了就别回头了
走了就别回头了 2021-01-21 04:15

I have a simple question.
Why is it necessary to consider the terminating null in an array of chars (or simply a string) and not in an array of integers. So when i want a

9条回答
  •  面向向阳花
    2021-01-21 04:47

    Actually - you don't have to NUL-terminate your strings if you don't want to! The only problem is you have to re-write all the string libraries because they depend on them. It's just a matter of doing it the way the library expects if you want to use their functionality.

    Just like I have to bring home your daughter at midnight if I wish to date her - just an agreement with the library (or in this case, the father).

提交回复
热议问题