How to remove first character from C-string?

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

    Here is my code

    char  * bastakiniSil(char *contents){
    char *p = malloc( sizeof(*p) * strlen(contents) );
    int i;
    for(i=0; i<strlen(contents); i++)
    {
        p[i]=contents[i+1];
    }
    
    return p;
    

    }

    0 讨论(0)
提交回复
热议问题