How to remove first character from C-string?

后端 未结 7 1186
小鲜肉
小鲜肉 2021-02-04 01:52

Can anyone please help me? I need to remove the first character from a char * in C.

For example, char * contents contains a \'\\n\'

7条回答
  •  隐瞒了意图╮
    2021-02-04 02:27

    It sounds as if you're under the impression that a char* "contains" characters. It does not. It merely points at a byte. The rest of the string is implied to consist of the subsequent byte in memory up until the next null byte. (You should also be aware that although the 'char' data type is a byte, by definition, it is not really a character - please be aware of Unicode - and nor is a byte necessarily an octet.)

    The char* is not an array, either, although there may exist an array of characters such that the pointer is pointing to the beginning of that array.

提交回复
热议问题