What is the default encoding for C strings?

后端 未结 5 885
后悔当初
后悔当初 2020-12-01 11:34

I know that C strings are char[] with a \'\\0\' in the last element. But how are the chars encoded?

Update: I found this cool link which talks about many other prog

5条回答
  •  醉酒成梦
    2020-12-01 11:41

    They are not really "encoded" as such, they are simply stored as-is. The string "hello" represents an array with the char values 'h', 'e', 'l', 'l', 'o' and '\0', in that order. The C standard has a basic character set that includes these characters, but doesn't specify an encoding into bytes. It could be EBCDIC, for all you know.

提交回复
热议问题