How to remove first character from C-string?

后端 未结 7 1213
小鲜肉
小鲜肉 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:19

    char* contents_chopped = contents + 1;

    This will result in contents_chopped pointing to the same string, except the first char will be the next after \n

    Also, this method is faster.

提交回复
热议问题