What does it mean to be “terminated by a zero”?

前端 未结 7 643
伪装坚强ぢ
伪装坚强ぢ 2020-12-06 17:21

I am getting into C/C++ and a lot of terms are popping up unfamiliar to me. One of them is a variable or pointer that is terminated by a zero. What does it mean for a space

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-06 17:53

    Arrays and string in C is just a pointers to a memory location. By pointer you can find a start of array. The end of array is undefined. The end of character array (which is the string) is zero-byte.

    So, in memory string hello is written as:

    68 65 6c 6c 6f 00                                 |hello|
    

提交回复
热议问题