What is the difference between a Character Array and a String?

后端 未结 10 1119
眼角桃花
眼角桃花 2020-12-10 11:49

Spending my time on high level languages it suddenly occurred to me that I did not know the difference between a Character Array and a String. I think they are the same thin

10条回答
  •  再見小時候
    2020-12-10 12:27

    In C these are almost the same, though a string will have an additional null character at the end.

    In other languages (Java, C# etc), a string is an object, whereas a character array is an array of ... chars (which are primitive data types).

    Normally, strings are implemented with character arrays.

提交回复
热议问题